Page 1 of 1

Script problem

PostPosted: Thu Aug 22, 2013 8:15 am
by Goettsch
I am not so good in scripting,know someone what is wrong in this script

player>create actor>script editor
Code: Select all
launchbomb = 15;



key down>space>script editor
Code: Select all
launchbomb=launchbomb-1;

if (launchbomb>0);
{
CreateActor("bomb", "bomb", "(none)", "(none)", 0, 0, false);
}

Re: Script problem

PostPosted: Thu Aug 22, 2013 8:29 am
by skydereign
Goettsch wrote:I am not so good in scripting,know someone what is wrong in this script

You need to tell use the problem you are having. It could be several different things. If I were to guess, I'd say it is that the keydown event is set to repeat, and therefore you fire all 15 shots within half a second. To fix that set the event not to repeat, or use some form of timing condition. Another possibility is that it goes into negative ammo, which is undesirable. The fix for that is to put the first line that decrements launchbomb into the if statement. That way it won't reduce launchbomb when it doesn't fire a bomb.

Re: Script problem

PostPosted: Thu Aug 22, 2013 3:15 pm
by Goettsch
skydereign wrote:I'd say it is that the keydown event is set to repeat, and therefore you fire all 15 shots within half a second.


It isn't this,I think it's the second case.

Re: Script problem

PostPosted: Thu Aug 22, 2013 4:21 pm
by lcl
Also, you are not supposed to have a ";" after if-statements.

Re: Script problem

PostPosted: Fri Aug 23, 2013 12:20 pm
by Goettsch
lcl wrote:Also, you are not supposed to have a ";" after if-statements.


Thanks,but it works with the ; too.


Thanks sky I solved the problem.

Re: Script problem

PostPosted: Fri Aug 23, 2013 6:57 pm
by skydereign
Goettsch wrote:Thanks,but it works with the ; too.

It shouldn't work. By putting that after the if statement, the actor will always be created.
Code: Select all
if(x<0);
{
    // this will always run, even if x>=0
}

The semicolon stops the statement, and the following three lines are treated like a standard code block.

Re: Script problem

PostPosted: Sat Aug 24, 2013 10:47 am
by Goettsch
Ahh,thanks