Programming Question Adding 'payloads' to .dll vessels. (e. g. Dropships and such)

Columbia42

Member
Joined
Dec 4, 2009
Messages
884
Reaction score
0
Points
16
Location
C:\ProgramFiles\Orbiter
I'm trying to add a payload (like the kind that are defined in sc3 .ini files) to a .dll spacecraft. I found a source file for an addon that has a dropship and therefore some way to jettison it but when I try to copy that section of the .cpp file into my file, the compiler I'm using comes up with all these errors. What format should I use to define something like this?
 
All what errors? What code?

Help us to help you. The more information, the better.
 
Syntax errors and the like. Here's the build log:

1>------ Build started: Project: Cosmos 47, Configuration: Debug Win32 ------
1>Compiling...
1>Cosmos 47.cpp
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(111) : error C2065: 'launch' : undeclared identifier
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(115) : error C2065: 'launch' : undeclared identifier
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(141) : error C2065: 'launch' : undeclared identifier
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(143) : error C2065: 'timering' : undeclared identifier
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(143) : error C2065: 'timering' : undeclared identifier
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(145) : error C2065: 'timering' : undeclared identifier
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(147) : error C2065: 'launch' : undeclared identifier
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(154) : error C2059: syntax error : '}'
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(154) : error C2143: syntax error : missing ';' before '}'
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(154) : error C2059: syntax error : '}'
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(163) : error C2143: syntax error : missing ';' before '{'
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmos 47.cpp(163) : error C2447: '{' : missing function header (old-style formal list?)
1>Build log was saved at "file://c:\Program Files\Orbiter\Orbitersdk\samples\TestProject\Debug\BuildLog.htm"
1>Cosmos 47 - 12 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

When I removed the section of the file defining the jettison of the dropship, all of the errors went away.
 
It looks very much like you have syntax errors in your code. Maybe if you put your code in a pastebin and posted the link we could see where the error is.
 
Here's the code I used for the payload jettison definition:

// Jettison Dropship


if (launch ==1 )
{




launch = 2;


DelMesh (2);


VESSELSTATUS2 vs;
memset (&vs, 0,
sizeof (vs));
vs.version = 2;
GetStatusEx (&vs);
//vs.flag = VS_FUELREGET | VS_THRUSTREGET;
VECTOR3 ofs = _V(0,-2.5,2.222);
VECTOR3 rofs, rvel = {vs.rvel.x, vs.rvel.y, vs.rvel.z};
VECTOR3 vel = {0,-10,0};
Local2Rel (ofs, vs.rpos);
GlobalRot (vel, rofs);
vs.rvel.x = rvel.x+rofs.x;
vs.rvel.y = rvel.y+rofs.y;
vs.rvel.z = rvel.z+rofs.z;
vs.vrot.x = -0.02;
vs.status = 0;


oapiCreateVesselEx (
"K-X-1A-v3","K33\\K-X-1A-v3",&vs);


SetEmptyMass (12000.0);


}


if (launch == 2)
{
timering = timering + 0.33 ;


if (timering >= 27)
{
launch = 3;
oapiSetFocusObject(oapiGetVesselByName(
"K-X-1A-v3"));



}
}
}

BTW, it's not my code. I just copied it off of a source file for another addon.
 
Code:
if (launch == 2)
{
timering = timering + 0.33 ;


if (timering >= 27)
{
launch = 3;
oapiSetFocusObject(oapiGetVesselByName("K-X-1A-v3"));



}
}
}

The second conditional will never be hit in this instance, because it's inside another one which precludes it.

This is by far not the only problem, but the sample you provided is too narrow-scope. Where are you defining "launch" and "timering" ?

Please pastebin the -full- code.
 
These errors make it look like he's not defining them at all, but I could be wrong
Code:
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmo s 47.cpp(145) : error C2065: 'timering' : undeclared identifier
1>c:\program files\orbiter\orbitersdk\samples\testproject\cosmo s 47.cpp(147) : error C2065: 'launch' : undeclared identifier
 
This is pastebin: http://pastebin.com/ it's a pretty cool website that allows you to upload code and link to it, without uploading a file with the code in
edit: are you sure that's your full code ?... you seem to be missing a lot of essential things
 
Last edited:
Okay...

It seems like that was your entire code, which is where your problem is in its entirety.

You need a lot more than this to make a vessel module. Have a look inside the \orbitersdk\samples\shuttlepb folder for the simplest example.

Vessel modules are much more complicated than just that.

Edit; Having seen your new upload, I'm somewhat confused. Which file represents the code you are actually using?
 
I've added the code to pastebin here -> http://pastebin.com/WE8722rF

I'm no programmer but the first thing I've spotted is the line

if (launch ==1 )

But you are evaluated a variable you haven't defined so the compiler will look at this and have no idea what launch is because it's not defined anyway. The code will never work.
 
I've added the code to pastebin here -> http://pastebin.com/WE8722rF

I'm no programmer but the first thing I've spotted is the line

if (launch ==1 )

But you are evaluated a variable you haven't defined so the compiler will look at this and have no idea what launch is because it's not defined anyway. The code will never work.

Than how does the addon that uses this code (K33's B-29 and X-1A) work?
 
Have you actually looked at the source file you pulled that code from? The variables are defined right at the top of it.
 
One of the first line in the source for the addon you linked is:

#define LAUNCH 4

So there you go, a variable called launch that's defined. The addon has a lot more source thans yours. You CAN borrow someone elses source code but you need to have an understanding of its doing, you also need a rudimetary understanding of C++ just deleting things won't do anything except leave you in the mess you are now in.
 
Like I said earlier, check out the samples folder of the SDK. The code in those folders was provided so that people could study it and learn how to write vessel modules for Orbiter. The ShuttlePB code is perhaps the most simple, so it's a good place to begin. Read the code and try to follow it, see what does what, what leads in to what, and, since you know what the code produces in the end (The ShuttlePB itself) you should be able to work it out.

It takes time to learn, and it isn't simple. A basic understanding of coding principles is essential, and some knowledge of C++ would be helpful. You can find resources to help you get a grasp of both on the internet.
 
One of the first line in the source for the addon you linked is:

#define LAUNCH 4

So there you go, a variable called launch that's defined. The addon has a lot more source thans yours. You CAN borrow someone elses source code but you need to have an understanding of its doing, you also need a rudimetary understanding of C++ just deleting things won't do anything except leave you in the mess you are now in.

The reason why I started this thread was not really to find out why the code I copied was not working in my file (though I really appreciate your helping a complete novice at Orbiter developing such as myself) but to find out how to define a jettisonable payload in a C++ file. Is this source file an example of the best way to do that or is there some better way?
 
When you speak of "jettisoning", you could also take a look at how the stock Atlantis handles separating her SRBs and ET. Just look in the code and you will find a section very similar to the one you posted.

Atlantis' source code is complex, however, so I would advise you to look at simpler examples beforehand, as mentioned earlier.
 
The Atlantis code handles that through attachments (I'm relatively certain) and I would like to avoid doing that because I am planning on launching the spacecraft I am developing on a multistage 2 rocket which (unless I am mistaken) doesn't support attachments.
 
Back
Top