- Joined
- Jan 5, 2009
- Messages
- 217
- Reaction score
- 0
- Points
- 16
- Location
- Near Verona
- Website
- orbiteritalia.forumotion.com
Hi guys
I have a problem with saving the state of the scenario.
I have a door that I would like to open and close, and save the state in the scenario, but every time I start the scenario the door is always closed.
What's wrong?
I thank all those who can help :tiphat:
I have a problem with saving the state of the scenario.
I have a door that I would like to open and close, and save the state in the scenario, but every time I start the scenario the door is always closed.
What's wrong?
Code:
// --------------------------------------------------------------
// Read status from scenario file
// --------------------------------------------------------------
void ShuttlePB::clbkLoadStateEx (FILEHANDLE scn, void *vs)
{
char *line;
while (oapiReadScenario_nextline (scn, line)) {
if (!strnicmp (line, "HATCH1", 4)) {
sscanf (line+4, "%d%lf", &hatch1_status, &hatch1_proc);
}
else {
ParseScenarioLineEx (line, vs);
// unrecognised option - pass to Orbiter's generic parser
}
}
}
// --------------------------------------------------------------
// Write status to scenario file
// --------------------------------------------------------------
void ShuttlePB::clbkSaveState (FILEHANDLE scn)
{
char cbuf[256];
// Write default vessel parameters
VESSEL2::clbkSaveState (scn);
if (hatch1_status) {
sprintf (cbuf, "%d %0.4f", hatch1_status, hatch1_proc);
oapiWriteScenario_string (scn, "HATCH1", cbuf);
}
}
// --------------------------------------------------------------
// Respond to playback event
// --------------------------------------------------------------
bool ShuttlePB::clbkPlaybackEvent (double simt, double event_t, const char *event_type, const char *event)
{
if (!stricmp (event_type, "HATCH1")) {
ActivateHatch1 (!stricmp (event, "OPEN") ? DOOR_CLOSING : DOOR_OPENING);
return true;
}
return false;
}
void ShuttlePB::clbkSetStateEx(const void *status)
{
DefSetStateEx(status);
}
void ShuttlePB::clbkPostCreation()
{
//Set animation states
SetAnimation (anim_hatch1, hatch1_proc);
}