Hi!
1. I have this custom door COG, where if you hit a switch, the door will open or close. Now, I've set so that if you activate the door, it will play a locked sound indicating you'll need to activate a switch. Problem is that when I activate the door, the door opens... Why is that?
2. I have this draw bridge, and I wanted to add a little bounce effect when it comes to its level position. I managed to make that bounce effect, only, it's never straight after it bounces. So I try to set the origentation with a SetThingLook. Result: it disappears. Are there any other ways of solving this?
/Edward
1. I have this custom door COG, where if you hit a switch, the door will open or close. Now, I've set so that if you activate the door, it will play a locked sound indicating you'll need to activate a switch. Problem is that when I activate the door, the door opens... Why is that?
Code:
# Door Set 2
#
# By Edward
symbols
message startup
message activated
surface switch1
surface switch2
thing door
thing doorthing
thing bolt1
thing bolt2
int ch1=1 local
int open=0 local
flex speed
sound rotation
sound moving
sound bump
end
#
code
startup:
MoveToFrame(door,0,100);
SetWallCel(switch1,0);
SetWallCel(switch2,0);
return;
activated:
if((GetSenderRef()==switch1) || (GetSenderRef()==switch2))
{
if(open==0)
{
open=2;
SetWallCel(switch1,1);
SetWallCel(switch2,1);
ch1=PlaySoundThing(rotation,bolt1,1,-1,-1,0x80);
ChangeSoundPitch(ch1,0.75+rand()*0.50,0.1);
ch1=PlaySoundThing(rotation,bolt2,1,-1,-1,0x80);
ChangeSoundPitch(ch1,0.75+rand()*0.50,0.1);
SetThingRotVel(bolt1,'0 0 -90');
SetThingRotVel(bolt2,'0 0 90');
sleep(1);
StopThing(bolt1);
StopThing(bolt2);
ch1=PlaySoundThing(moving,bolt1,1,-1,-1,0x80);
ChangeSoundPitch(ch1,0.75+rand()*0.50,0.1);
ch1=PlaySoundThing(moving,bolt2,1,-1,-1,0x80);
ChangeSoundPitch(ch1,0.75+rand()*0.50,0.1);
SetThingVel(bolt1,'.2 0 0');
SetThingVel(bolt2,'-.2 0 0');
sleep(1);
StopThing(bolt1);
StopThing(bolt2);
AttachThingToThing(doorthing,door);
MoveToFrame(door,1,speed);
WaitForStop(door);
SetWallCel(switch1,0);
SetWallCel(switch2,0);
open=1;
}
else if(open==1)
{
open=2;
SetWallCel(switch1,1);
SetWallCel(switch2,1);
AttachThingToThing(doorthing,door);
MoveToFrame(door,0,speed);
WaitForStop(door);
ch1=PlaySoundThing(moving,bolt1,1,-1,-1,0x80);
ChangeSoundPitch(ch1,0.75+rand()*0.50,0.1);
ch1=PlaySoundThing(moving,bolt2,1,-1,-1,0x80);
ChangeSoundPitch(ch1,0.75+rand()*0.50,0.1);
SetThingVel(bolt1,'-.2 0 0');
SetThingVel(bolt2,'.2 0 0');
sleep(1);
StopThing(bolt1);
StopThing(bolt2);
ch1=PlaySoundThing(rotation,bolt1,1,-1,-1,0x80);
ChangeSoundPitch(ch1,0.75+rand()*0.50,0.1);
ch1=PlaySoundThing(rotation,bolt2,1,-1,-1,0x80);
ChangeSoundPitch(ch1,0.75+rand()*0.50,0.1);
SetThingRotVel(bolt1,'0 0 90');
SetThingRotVel(bolt2,'0 0 -90');
sleep(1);
StopThing(bolt1);
StopThing(bolt2);
SetWallCel(switch1,0);
SetWallCel(switch2,0);
open=0;
}
}
else if(GetSenderRef()==doorthing)
{
PlaySoundThing(bump,doorthing,1,-1,-1,0x80);
}
return;
end2. I have this draw bridge, and I wanted to add a little bounce effect when it comes to its level position. I managed to make that bounce effect, only, it's never straight after it bounces. So I try to set the origentation with a SetThingLook. Result: it disappears. Are there any other ways of solving this?
Code:
# The Bridge
#
# By Edward
symbols
message startup
message activated
message pulse
thing bridge1
thing bridge2
surface switch1
surface switch2
sound bridge1start
sound bridge1move
sound bridge1stop
sound bridge2start
sound bridge2move
sound bridge2stop
int drawn1=0 local
int drawn2=0 local
int ch1=1 local
int ch2=2 local
int i local
end
#
code
startup:
sleep(.5);
SetPulse(0.1);
MoveToFrame(bridge2,0,100);
WaitForStop(bridge2);
sleep(.5);
RotatePivot(bridge1,1,1);
SetPulse(0.1);
return;
activated:
if(GetSenderRef()==switch1)
{
If(drawn2!=0) return;
if(drawn1==0)
{
drawn1=2;
ch2=PlaySoundThing(bridge1start,bridge1,1,-1,-1,0x80);
ChangeSoundPitch(ch2,.25,0.1);
ch1=PlaySoundThing(bridge1move,bridge1,1,-1,-1,0x81);
RotatePivot(bridge1,1,-10);
WaitForStop(bridge1);
StopSound(ch1,1);
ch2=PlaySoundThing(bridge1stop,bridge1,1,-1,-1,0x80);
ChangeSoundPitch(ch2,.25,0.1);
// for(i=10; i<50; i=i+1)
// {
// RotatePivot(bridge1,1,i);
// sleep(0.01);
// }
// for(i=50; i>6; i=i-1)
// {
// RotatePivot(bridge1,1,-i);
// sleep(0.01);
// }
// StopThing(bridge1);
sleep(1);
drawn1=1;
}
else if(drawn1==1)
{
drawn1=2;
ch2=PlaySoundThing(bridge1start,bridge1,1,-1,-1,0x80);
ChangeSoundPitch(ch2,.25,0.1);
ch1=PlaySoundThing(bridge1move,bridge1,1,-1,-1,0x81);
RotatePivot(bridge1,1,15);
WaitForStop(bridge1);
StopSound(ch1,1);
ch2=PlaySoundThing(bridge1stop,bridge1,1,-1,-1,0x80);
ChangeSoundPitch(ch2,.25,0.1);
// for(i=15; i<50; i=i+1)
// {
// RotatePivot(bridge1,1,-i);
// sleep(0.01);
// }
// for(i=50; i>9; i=i-1)
// {
// RotatePivot(bridge1,1,i);
// sleep(0.01);
// }
// StopThing(bridge1);
sleep(1);
drawn1=0;
}
}
else if(GetSenderRef()==switch2)
{
if(drawn1!=1) return;
if(drawn2==0)
{
drawn2=2;
ch2=PlaySoundThing(bridge2start,bridge2,1,-1,-1,0x80);
ChangeSoundPitch(ch2,.25,0.1);
ch1=PlaySoundThing(bridge2move,bridge2,1,-1,-1,0x81);
MoveToFrame(bridge2,1,4);
WaitForStop(bridge2);
StopSound(ch1,1);
ch2=PlaySoundThing(bridge2stop,bridge2,1,-1,-1,0x80);
ChangeSoundPitch(ch2,.25,0.1);
drawn2=1;
}
else if(drawn2==1)
{
drawn2=2;
ch2=PlaySoundThing(bridge2start,bridge2,1,-1,-1,0x80);
ChangeSoundPitch(ch2,.25,0.1);
ch1=PlaySoundThing(bridge2move,bridge2,1,-1,-1,0x81);
MoveToFrame(bridge2,0,4);
WaitForStop(bridge2);
StopSound(ch1,1);
ch2=PlaySoundThing(bridge2stop,bridge2,1,-1,-1,0x80);
ChangeSoundPitch(ch2,.25,0.1);
drawn2=0;
}
}
return;
pulse:
SetWallCel(switch1,drawn1);
SetWallCel(switch2,drawn2);
ChangeSoundPitch(ch1,.75+(rand()*.5),0.1);
AttachThingToThing(bridge2,bridge1);
return;
end/Edward