I want this cog to open a door when panel is damaged. You damage panel, door opens, r2 unit comes out repairs panel and goes back, doors close. But it doesn't work...
symbols
message damaged
message pulse
surface panel linkid=1
thing sparkspos local
thing door
thing r2
template sparks=+sparks
int status=0 local
end
# ========================================================================================
code
damaged:
sparkspos = GetSurfaceCenter(panel);
if(GetSenderID() == 1)
{
status = 1;
SetSurfaceCel(panel,1);
SetPulse(1);
Sleep(1.0);
MoveToFrame(door, 1, 8);
WaitForStop(door);
AiSetMoveFrame(r2, 1);
WaitForStop(r2);
AiSetMoveFrame(r2, 2);
WaitForStop(r2);
AiSetLookPos(r2, sparkspos);
Sleep(10.0);
SetPulse(0);
AiSetMoveFrame(r2, 1);
WaitForStop(r2);
AiSetMoveFrame(r2, 0);
WaitForStop(r2);
MoveToFrame(door, 0, 1);
Sleep(1.0);
act = 0;
}
else
if(status == 1) return;
return;
# ........................................................................................
pulse:
CreateThing(sparks, sparkspos);
return;
# ........................................................................................
end
Maybe this helps to imagine how it's meant to be:
------------------
*Elmo is Elmo
Elmo's JK Corner
[This message has been edited by Elmo (edited December 02, 2001).]
symbols
message damaged
message pulse
surface panel linkid=1
thing sparkspos local
thing door
thing r2
template sparks=+sparks
int status=0 local
end
# ========================================================================================
code
damaged:
sparkspos = GetSurfaceCenter(panel);
if(GetSenderID() == 1)
{
status = 1;
SetSurfaceCel(panel,1);
SetPulse(1);
Sleep(1.0);
MoveToFrame(door, 1, 8);
WaitForStop(door);
AiSetMoveFrame(r2, 1);
WaitForStop(r2);
AiSetMoveFrame(r2, 2);
WaitForStop(r2);
AiSetLookPos(r2, sparkspos);
Sleep(10.0);
SetPulse(0);
AiSetMoveFrame(r2, 1);
WaitForStop(r2);
AiSetMoveFrame(r2, 0);
WaitForStop(r2);
MoveToFrame(door, 0, 1);
Sleep(1.0);
act = 0;
}
else
if(status == 1) return;
return;
# ........................................................................................
pulse:
CreateThing(sparks, sparkspos);
return;
# ........................................................................................
end
Maybe this helps to imagine how it's meant to be:
------------------
*Elmo is Elmo
Elmo's JK Corner
[This message has been edited by Elmo (edited December 02, 2001).]
* Elmo is Elmo