script object, IF statement??

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
fuhrer
Captain
Posts: 253
Joined: Sun Mar 14, 2004 3:36 am

script object, IF statement??

Post by fuhrer »

ok heres my scenario, player enters room, door closes behind him, walls close in, he has to shoot a mult trigger to open a window, now this is the part i need help with, my script is relying on the player hittin the trigger,

this maybe unclear i woul post the whole script its a big long.

$window2 moveUp 64 <--i have that when the player hits the trigger.

and...

$window2 moveDown 64

at the end, (regardless of what happens, the window always moves down), so....

if the player misses the trigger the window will not move up but will still move down and generally screw it up.


basically if the player misses the trigger and gets squashed, window2 must not move down.


if u want to see the script i can post it, or send it over msn.

Im not sure if i need an IF statement in there or some kind of variable, im not sure how those work yet, ive looked at a lot of eg maps n stuff in the bin but i cant quite get my head around em.

for instance, i took this from tltrudes door script hope you dont mind, but in the elevator prep section u have...

level.elepos = 0 // Defines the position of the elevator. "0 - down" "1 - up"

i can see how that defines the position but im still unsure of how the game knows you are talking about the elevator.
dcoshea
Colour Sergeant
Posts: 94
Joined: Thu Mar 04, 2004 3:00 am
Location: Sydney, Australia
Contact:

Post by dcoshea »

fuhrer wrote:level.elepos = 0 // Defines the position of the elevator. "0 - down" "1 - up"

i can see how that defines the position but im still unsure of how the game knows you are talking about the elevator.
As I guess you've learned in that other thread, when you create a variable like that it has no meaning at all to the game engine itself, only to your own code, so you need to check the value somewhere else using 'if'.

What event causes teh window to go down? Could it go down a fixed amount of time after it goes up? If so, you could just put the 'moveDown' in the same thread which is called after the player hits the trigger, e.g.:

Code: Select all

$window2 moveUp 64
wait 5 // seconds
$window2 moveDown 64
Obviously the moveDown will only happen after the moveUp has happened and then a 5 second delay has occured in that example.

If you want the window to go down at a time determined via some other means, like after the walls have finished closing in, then you'd need to use some more complex coding involving an 'if' statement or something like that.

Regards,
David
chrisjbooth2001
Colour Sergeant
Posts: 77
Joined: Thu Dec 18, 2003 12:57 am

Post by chrisjbooth2001 »

Ok, I dunno if im right but...

If you make it so the trigger starts the thread that moves the window... So when player touches the trigger, THEN it starts the thread...

So it won't begin the thread unless the trigger is touched...
fuhrer
Captain
Posts: 253
Joined: Sun Mar 14, 2004 3:36 am

Post by fuhrer »

thankyou for the input but tltrude helped me with this one, i just needed to understand the whole variables thing n i sorted it myself.
Post Reply