Page 1 of 1
variables
Posted: Fri Mar 19, 2004 12:39 pm
by fuhrer
probably seem relativly stupid question but...
Creating variables
This is easy: just name it, and it will exist.
local.index = 0
what would index be referring to, and how would the game know what 0 is, yes or no up or down but how does it know what u are talking about?
would you have to use a targetname or saywindow. n have it move up or down then as the variable it would be
level.window = 0 (down)
level.window = 1 (up)
i cant see that workin as how would the game know where 0 and 1 are.
simple explanation please
Posted: Fri Mar 19, 2004 3:06 pm
by jv_map
Well the game doesn't. It only remembers whether you've set it to 1 or 0.
Then further below in your script you could have something like this:
Code: Select all
if(level.window == 1)
$window open
else if(level.window == 0)
$window close
else
println "error, level.window was " level.window ", should be 1 (open) or 0 (closed)"
So it's basically your decision whether 1 or 0 represent open or closed, or maybe even something completely different...
Posted: Fri Mar 19, 2004 3:06 pm
by Angex
I'm not sure wich is correct but there could be two possiblities:
1.MoH appears to cast a type to the declaration after it has been initialised.
2.MoH doesn't care about semantics too much.
In your example local.index represents an integer, of the value zero. It can be used in your script to represent what ever you want. E.G.
fuher wrote:what 0 is, yes or no
A boolean could be represented using true = 1, false = 0.
fuher wrote:would you have to use a targetname or saywindow. n have it move up or down then as the variable it would be
Typically games use matricies to calculate translation, rotation, scalling etc. The scripting language provides commands to interface with the game engine in order to do this.
Posted: Fri Mar 19, 2004 3:27 pm
by fuhrer
i dont understand
Posted: Fri Mar 19, 2004 3:40 pm
by jv_map
fuhrer wrote:i dont understand
Either read again or tell us what part you don't understand...
Posted: Sat Mar 20, 2004 2:35 am
by fuhrer
so far.. i think i understand this....
"level." is referring to a script object in radiant (does that include triggers) and "window" would be the targetname of that script object..
is that correct?
now what i dont understand is ...where u set it as 0
do u do this at prespawn or in the thread itself?
settin it at 0, the game recognises 0 as the position the window is in when the variable is set...
i.e. if the origin of the object is at 0 on the x axis
level.window = 0 = 0 on the x axis...
therefore
level.window = 1 = object being anywhere else.
my script would be...
Code: Select all
level waittill spawn
$trapdoor_trigger nottriggerable
level.window2 = 0
end
and the thread that moves the window..
Code: Select all
window2: // this thread is set by a goto from the previous thread
if (level.window2 == 1) // if window2 is in different position than it started in
{
$window2 moveDown 64
$window2 move
goto door return
}
else
{
goto door return
}
end
door_return:
$crusher_door moveUp 120
$crusher_door playsound m1l2b_disabletruck
$window1 moveDown 64
$crusher_door move
$window1 waitmove
$window_trigger triggerable
$trapdoor_trigger triggerable
end
ok so this is how its makin sense in my head right now, but its not working so what am i gettin confused with?
nope
Posted: Sat Mar 20, 2004 3:52 am
by tltrude
I only read the first part of your last post. You are looking at variables as if they are script commands , and they are not. They are just names you make up. So, the last part of the variable name can be anything you like.
level.broke_glass
local.glass_busted
level.windows_points
The value of these variables are all "NIL" because no value has been set for them yet. It does not matter where you set the value for them in the script, but they must be set before they are needed, or the value will be "NIL". However, "local" means in the current thread and "level" means in any thread.
The value can be set to a number, or a string of letters, or even a value from some entity in the game.
level.break_glass = 100
local.glass_busted = "not broken"
level.windows_points = $my_window.health
"$my_window.health" is the current health value of an entity targetnamed "my_window"--func_window starts with health 250. So, if you want, you can change the health of it in the script like this.
$my_window.health = level.break_glass
Hope that helps