Page 1 of 1

-= help

PostPosted: Thu Mar 06, 2008 11:48 pm
by trippola77
yep another question.
Im makeing a game where you wander the desert along the noncopyrighted "Silk path". :wink:
I have a waterlevel and it is a textnumber.
Now when the actor is created it creates a timer and when the timer goes off its supposed to subract 2.
this is the code i use
waterlevel.textNumber = waterlevel.textNumber -= 2;
But when i do that the textnumber becomes -2.
I tried to correct the code, but then it equals -1.
is there something wrong with the code?

Re: -= help

PostPosted: Fri Mar 07, 2008 12:10 am
by Freddy
Try this:
waterlevel.textnumber = waterlevel.textnumber - 2;
I think that should work. :D

Re: -= help

PostPosted: Fri Mar 07, 2008 12:20 am
by trippola77
i still came up as -1.
Heres the exact thing i do.
Create actor/ creatimer
timer
waterlevel, periodic, 10000 ms, forever

Timer / script editor
waterlevel.textNumber = waterlevel.textNumber -=2;
Then it comes up as -2

When i did your approach it came up as
-1;

Re: -= help

PostPosted: Fri Mar 07, 2008 12:23 am
by Freddy
Huh... Is waterlevel a variable or an actor?

Re: -= help

PostPosted: Fri Mar 07, 2008 12:28 am
by trippola77
its an actor

Re: -= help

PostPosted: Fri Mar 07, 2008 10:55 am
by edh
This is unnecessary:
Code: Select all
waterlevel.textNumber = waterlevel.textNumber -=2;


You should be able to do
Code: Select all
waterlevel.textNumber -=2;


or
Code: Select all
waterlevel.textNumber = waterlevel.textNumber - 2;