Page 1 of 3
scripting - number value increase?
Posted: Fri Jan 14, 2005 1:26 am
by HDL_CinC_Dragon
is there a way to have a scripted number value increase by a certain amount? like:
or something like that.
Posted: Fri Jan 14, 2005 7:53 am
by jv_map
local.time += 5 // to increase 5
local.time++ // to increase 1
local.time -= 5 // to decrease 5
local.time-- // to decrease 1

Posted: Fri Jan 14, 2005 7:52 pm
by HDL_CinC_Dragon
=) thanks man! would that work with
does that start at zero and go up by fives?
how do you tell wether its going by fives every second or whatever?
and what if i have
would that work?
Posted: Fri Jan 14, 2005 9:03 pm
by Green Beret
whats the 10 for? i think it goes off your regular round time and adds onto that.not sure tho.
Posted: Sat Jan 15, 2005 12:27 pm
by bdbodger
local.variable = local.varible + 5
is the same as
local.variable += 5
I don't know if you can use $thing.time += 5 or if you can read it that way or not . To be safe or if that does not work you can try
local.time = 10
while(1)
{
$thing time local.time
$thing moveto local.spot1
$thing move
wait 1
$thing moveto local.spot2
$thing move
local.time += 5
}
something like that will work .
Posted: Sat Jan 15, 2005 3:05 pm
by HDL_CinC_Dragon
ok, what if i have
Code: Select all
main:
...
level waittil prespawn
thread thing_overseer
local.time = 10
...
end
level waittill spawn
thing_overseer:
while(1)
}
$trigger waittill trigger
$trigger nottriggerable
wait 1
$thing moveeast 1000
local.time +=5
...
{
end
do you thing that would work?... and this +=5 thing, does it keep adding 5 to the speed every second or something? cuz thats what i want it to do...
Posted: Sat Jan 15, 2005 5:43 pm
by lizardkid
no, no no.
you cannot have statements outside threads, it generates errors and is never used.
you need openeing and closing braces. {}.
you made them backwards
for overseer here's what will work, every second it adds 5 to time.
Code: Select all
thing_overseer:
while(1)
{
$trigger nottriggerable
wait 1
$thing.time +=5
$thing moveeast 1000
}
end
also, it's a lot better imo to use setthread on the trigger so you don't have a bunch of waittills circulating, it's easier on memory... plus it's easier to read.
Posted: Sat Jan 15, 2005 9:08 pm
by HDL_CinC_Dragon
thanx man

Posted: Sat Jan 15, 2005 9:35 pm
by bdbodger
The only thing is that script will send it off the map and keep it moveing into infility . It has to stop sometime .
Posted: Sun Jan 16, 2005 3:25 am
by HDL_CinC_Dragon
ya I know, im using it in a script right now and i have it stop when it his 360 (im using it for rotation ? rather than time)
Posted: Sun Jan 16, 2005 5:12 am
by lizardkid
well for rotation you need to use one of 3 commands..
then a few numbers, look them up in G_allclasses.
moveeast just makes it move east...
Posted: Sun Jan 16, 2005 5:14 am
by HDL_CinC_Dragon
ya i know, ive mastered rotating and movement
Posted: Sun Jan 16, 2005 5:42 pm
by HDL_CinC_Dragon
care to tell me how to make this work?
Posted: Sun Jan 16, 2005 9:58 pm
by lizardkid
not quite sure what you want to accomplish... that bit won't work i dont think.
i assume you want the fan to speed up by 20 every second,
if so...
Code: Select all
local.fanSpeed = 1
while(local.fanSpeed < 100)
{
local.fanSpeed += 20
$fan3 rotateY local.fanSpeed
wait 5
}
every 5 seconds it'll pick up by 20, but for smoothness it's better to do something like this.
Code: Select all
for(local.fanSpeed = 1; local.fanSpeed < 100; local.fanSpeed++)
{
$fan3 rotateY local.fanSpeed
wait .5
}
i'm going to feel really stupid if this isn't what you wanted...
Posted: Mon Jan 17, 2005 1:47 am
by HDL_CinC_Dragon
it is very much what iu wanted, but i feel that up by 5 every second would be smoothness enough
Code: Select all
Code:
local.fanSpeed = 1
while(local.fanSpeed < 360)
{
local.fanSpeed += 5
$fan3 rotateY local.fanSpeed
wait 1
}
does this mean that if the speed value is lower than 360, it will continue to add 5 every second? cuz i want the "time" to stay one, but i want the rotation degree to increase by 5 every second until it thits 360 so that it will be going faster... and how would I encorperate these things into my current script?
Code: Select all
main:
setcvar "g_obj_alliedtext1" "HDL"
setcvar "g_obj_alliedtext2" "Testing"
setcvar "g_obj_alliedtext3" "Site"
setcvar "g_obj_axistext1" "HDL"
setcvar "g_obj_axistext2" "Testing"
setcvar "g_obj_axistext3" "Site"
setcvar "g_scoreboardpic" "none"
local.master = spawn ScriptMaster
aliascache fence_roll_open sound/mechanics/Fence_Open.wav soundparms 1.2 0.0 1.1 0.0 160 1600 item loaded maps "m2l2 HDL_Testing_Site dm obj "
aliascache explode_tank4 sound/weapons/explo/Explo_MetalMed4.wav soundparms 0.9 0.2 0.8 0.2 1500 9000 weapon loaded maps "m1l3a m1l3b m3l3 m4l2 m5 m6l3c HDL_Testing_site dm obj "
level waittill prespawn
$world northyaw 90
thread lift
$lift time 3
thread fans
$fan1 time 1
$fan2 time 1
$fan3 time 1
thread blastdoor
$blastdoor time 3.13
$wheels time 3.13
thread bombs_away
level waittill spawn
lift:
while(1)
{
$lifttrigger waittill trigger
$lifttrigger nottriggerable
$liftswitch anim turn
wait 1
$lift loopsound lighthouse_run
$lift moveup 504
$lift waitmove
$lift stoploopsound
$liftswitch anim turnoff
wait 1
$lifttrigger triggerable
$lifttrigger waittill trigger
$lifttrigger nottriggerable
$liftswitch anim turn
wait 1
$lift loopsound lighthouse_run
$lift movedown 504
$lift waitmove
$lift stoploopsound
$liftswitch anim turnoff
wait 1
$lifttrigger triggerable
waitframe
}
end
blastdoor:
while(1)
{
$blastdoortrigger waittill trigger
$blastdoortrigger nottriggerable
$blastdoorswitch anim turn
wait 1
$blastdoor loopsound fence_roll_open
$blastdoor rotateZ 57.5
$wheels rotateZ 57.5
wait 3.13
$wheels rotateZ 0
$blastdoor rotateZ 0
$blastdoor stoploopsound
wait 3
$blastdoortrigger triggerable
$blastdoortrigger waittill trigger
$blastdoortrigger nottriggerable
wait 1
$blastdoor loopsound fence_roll_open
$blastdoor rotateZ -57.5
$wheels rotateZ -57.5
wait 3.13
$wheels rotateZ 0
$blastdoor rotateZ 0
$blastdoor stoploopsound
wait 3
$blastdoortrigger triggerable
waitframe
}
end
fans:
while(1)
{
$fantrigger waittill trigger
$fantrigger nottriggerable
wait 1
iprintln "Fans 2 and 3 comming online - please wait..."
wait 1
$fan2 rotateY 90
$fan25 rotateY -90
$fan3 rotateY 90
$fan35 rotateY -90
wait 3
$fan2 rotateY 180
$fan25 rotateY -180
$fan3 rotateY 180
$fan35 rotateY -180
wait 3
$fan2 rotateY 270
$fan25 rotateY -270
$fan3 rotateY 270
$fan35 rotateY -270
wait 3
$fan2 rotateY 360
$fan25 rotateY -360
$fan3 rotateY 360
$fan35 rotateY -360
iprintln "Fans 2 and 3 are now online."
wait 1
iprintln "Fan 1 comming online - please wait..."
wait 1
$fan1 rotateX 45
wait 3
$fan1 rotateX 90
wait 3
$fan1 rotateX 135
wait 3
$fan1 rotateX 180
wait 3
$fan1 rotateX 225
wait 3
$fan1 rotateX 270
wait 3
$fan1 rotateX 315
wait 3
$fan1 rotateX 360
wait 1
iprintln "Fan 1 is now online."
wait 1
iprintln "To de-activate fan system, please re-animate the switch."
wait 1
$fantrigger triggerable
$fantrigger waittill trigger
$fantrigger nottriggerable
wait 1
iprintln "Fan 1 comming offline - please wait..."
wait 1
$fan1 rotateX 315
wait 3
$fan1 rotateX 270
wait 3
$fan1 rotateX 225
wait 3
$fan1 rotateX 180
wait 3
$fan1 rotateX 135
wait 3
$fan1 rotateX 80
wait 3
$fan1 rotateX 45
wait 3
$fan1 rotateX 0
wait 1
iprintln "Fan 1 is now offline."
wait 1
iprintln "Fans 2 and 3 are now comming offline - please wait..."
wait 1
$fan2 rotateY 270
$fan25 rotateY -270
$fan3 rotateY 270
$fan35 rotateY -270
wait 3
$fan2 rotateY 180
$fan25 rotateY -180
$fan3 rotateY 180
$fan35 rotateY -180
wait 3
$fan2 rotateY 90
$fan25 rotateY -90
$fan3 rotateY 90
$fan35 rotateY -90
wait 3
$fan2 rotateY 0
$fan25 rotateY 0
$fan3 rotateY 0
$fan35 rotateY 0
wait 1
iprintln "Fans 2 and 3 are now offline."
wait 1
iprintln "To activate fan system, please animate switch"
$fantrigger triggerable
waitframe
}
end
bombs_away:
while(1)
{
$bomber waittill trigger
$bomber nottriggerable
wait 1
$speaker1 playsound arty_leadinmp
wait 1
$speaker1 playsound explode_tank4
$mortar1 anim start
$speaker2 playsound arty_leadinmp
wait 1
$speaker2 playsound explode_tank4
$mortar2 anim start
$speaker3 playsound arty_leadinmp
wait 1
$speaker3 playsound explode_tank4
$mortar3 anim start
$speaker4 playsound arty_leadinmp
wait 1
$speaker4 playsound explode_tank4
$mortar4 anim start
$speaker5 playsound arty_leadinmp
wait 1
$speaker5 playsound explode_tank4
$mortar5 anim start
$speaker6 playsound arty_leadinmp
wait 1
$speaker6 playsound explode_tank4
$mortar6 anim start
$speaker7 playsound arty_leadinmp
wait 1
$speaker7 playsound explode_tank4
$mortar7 anim start
$bomber triggerable
waitframe
}
end
I scripted the increases when my original idea didnt work...