Page 1 of 1

level.variable++ levell.variable--

Posted: Tue Jun 07, 2005 12:12 am
by agentmad007
hello ,

if i write:

Code: Select all

level.variable = 0 
Then

Code: Select all

level.variable++
Will add +1.

My question is How to take out an unit of the level.variable ( sorta level.variable--)

my guess was:

Code: Select all

level.variable = 0
level.fix = 1

Code: Select all

level.variable = (level.variable - level.fix)
The console has not complained yet , but i am unsure if it will work as i want to.

Thx

--

Posted: Tue Jun 07, 2005 12:45 am
by tltrude
Here are a couple of thread fragments from the global/obj_dm.scr script. Notice the "level.bombs_planted" variable lines.
if (local.counter >= level.bomb_set_time)
{
iprintlnbold "A Bomb has been planted!"
if (level.planting_team == "allies")
self playsound dfr_objective_o
else
self playsound den_objective_o
thread bomb_waittill_defuse
thread bomb_waittill_explode
self.live = 1
level.bombs_planted ++
end
}

if (local.counter >= level.bomb_defuse_time)
{
iprintlnbold "A Bomb has been defused!"
if (level.defusing_team == "allies")
self playsound dfr_diffused_d
else
self playsound den_diffused_d
thread bomb_waittill_set //start first thread again
self.live = 0
level.bombs_planted --
end
}

Posted: Tue Jun 07, 2005 12:57 am
by agentmad007
Ok so the level.variable -- work lol.Thought it does not exist as i never corssed it in any scripts before.

THANKS

Posted: Tue Jun 07, 2005 1:06 am
by lizardkid
if the other number never changes (say you're always going to add 5) then you don't need another variable.

level.number += 5 // adds 5 to level.number
level.number -= 5 // subracts...
level.number++ // adds one
level.number-- // subtracts...

if you're say adding the player's health to his angles (why you would do this is beyond me) you'd do it like that.

local.weird = ( $player[local.i].health + $player[local.i].angles )

just as an example of when to use variables to add stuff ;)

Posted: Tue Jun 07, 2005 8:33 am
by jv_map
~`~`~ Script Error: cannot cast 'vector' to 'float' :( :P

Posted: Tue Jun 07, 2005 10:25 am
by bdbodger
local.weird = lizardkid :lol:

Posted: Tue Jun 07, 2005 4:27 pm
by lizardkid
angles is a vecter?

*checks*

wow... i thought it was just a number :'(

while(local.weird == "lizardkid")
{
self.laugh
}

Posted: Tue Jun 07, 2005 5:23 pm
by Elgan
ERROR: Command Overflow: Possible Infinate loop in thread.

okok sorry! :twisted: