my if's don't work. Can someone tell me what I'm doing wrong
Posted: Tue Jul 10, 2007 10:20 am
Can someone please gently tell me what I'm doing wrong, because I'm going batty because I can't get my if's to work in the script editor. I don't come from a C background, I'm used to things like if ship_dir=1 then do something, else do something else.
Here's what I want to happen: After my ship gets destroyed by an asteroid, I need to fly it back unto the screen, safe from harm for a couple seconds.
Here's what I'm doing:
I have a global variable called ship_visible. On the ship's create actor event I set ship_visible=1. When it gets destroyed, I create an explosion actor which plays the kaboom, and in a script I set ship_visible=0. Then for my asteroids, I have a script for the collion with the ship:
if (ship_visible=1)
{
CreateActor("boom", "boom", "(none)", "(none)", 0, 0, false);
}
thinking that if the ship hasn't been destroyed, destroy it, but don't if it has been. But it doesn't work. Now my ship is never destroyed, even though I set ship_visible=1 on creation of the ship. I looked up tutorials on C. This looks like the right construct. What am I doing wrong??? The variable is never changed, except by the explosion actor, which now isn't created. I'm confused.
without the If the ship gets blown up correctly, but when it comes back it too often gets nailed by another asteroid before it gets fully back on screen. I need to have it invulnerable for awhile.
I can't get any if something=somenumber to work. I can say if something>somenumber-1 and that works, but not if something=some number. I don't get it.
Here's what I want to happen: After my ship gets destroyed by an asteroid, I need to fly it back unto the screen, safe from harm for a couple seconds.
Here's what I'm doing:
I have a global variable called ship_visible. On the ship's create actor event I set ship_visible=1. When it gets destroyed, I create an explosion actor which plays the kaboom, and in a script I set ship_visible=0. Then for my asteroids, I have a script for the collion with the ship:
if (ship_visible=1)
{
CreateActor("boom", "boom", "(none)", "(none)", 0, 0, false);
}
thinking that if the ship hasn't been destroyed, destroy it, but don't if it has been. But it doesn't work. Now my ship is never destroyed, even though I set ship_visible=1 on creation of the ship. I looked up tutorials on C. This looks like the right construct. What am I doing wrong??? The variable is never changed, except by the explosion actor, which now isn't created. I'm confused.
without the If the ship gets blown up correctly, but when it comes back it too often gets nailed by another asteroid before it gets fully back on screen. I need to have it invulnerable for awhile.
I can't get any if something=somenumber to work. I can say if something>somenumber-1 and that works, but not if something=some number. I don't get it.