Page 1 of 2

code prob

PostPosted: Sun Feb 25, 2007 10:55 am
by DarkParadox
at the begining i set life=3
whats wrong with this code ???
Code: Select all
if(stab==1)
{
    DestroyActor("enemy1");
}
else
{
    life-1;
}

(by the way i set it on collision)

PostPosted: Sun Feb 25, 2007 11:06 am
by DilloDude
Try
Code: Select all
life -= 1;
(or -- is the same as -= 1)

PostPosted: Sun Feb 25, 2007 11:37 am
by DarkParadox
:( it did not work

PostPosted: Sun Feb 25, 2007 11:53 am
by Troodon
Try
life = life - 1

PostPosted: Sun Feb 25, 2007 1:24 pm
by Sgt. Sparky
tekdino wrote:Try
life = life - 1

Code: Select all
life -= 1;

PostPosted: Sun Feb 25, 2007 1:34 pm
by irblinx
Code: Select all
life--;


should also do the same thing

PostPosted: Sun Feb 25, 2007 1:44 pm
by Sgt. Sparky
is that still valid C?
:)

PostPosted: Sun Feb 25, 2007 4:07 pm
by Kodo
Sgt. Sparky wrote:is that still valid C?
:)


life++;
life = life + 1;
life += 1;
Are all ways of adding 1 to life


life--;
life = life - 1;
life -= 1;
Are all ways of subtracting 1 from life

All three methods are valid C, how you write it is all down to preference. Usually you'll start out writing the long version ( life = life - 1; ) just because its easily understandable, but all methods provide the same result :)

PostPosted: Sun Feb 25, 2007 11:17 pm
by Game A Gogo
their also Valid C++ ;)

PostPosted: Mon Feb 26, 2007 12:00 am
by Sgt. Sparky
I was only askin' bout' the -- :P




:D

PostPosted: Mon Feb 26, 2007 2:08 am
by DilloDude
diormeh wrote::( it did not work
What is it doing?

PostPosted: Mon Feb 26, 2007 2:51 am
by HillBilly
Did you rember so set up the "Life" variable in global?

PostPosted: Mon Feb 26, 2007 3:14 am
by Sgt. Sparky
or as an actor var if you have many actors :D

PostPosted: Wed Feb 28, 2007 11:25 pm
by DarkParadox
noothiing worrksss :cry: :cry: :cry: :cry:

PostPosted: Thu Mar 01, 2007 12:01 am
by DilloDude
Which part isn't working? is the actor not destoying? Is life not changing? or all of the above?