variables

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
fuhrer
Captain
Posts: 253
Joined: Sun Mar 14, 2004 3:36 am

variables

Post 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
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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...
Last edited by jv_map on Fri Mar 19, 2004 3:08 pm, edited 2 times in total.
Image
Angex
Major
Posts: 293
Joined: Mon Dec 30, 2002 1:23 pm
Contact:

Post 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.
fuhrer
Captain
Posts: 253
Joined: Sun Mar 14, 2004 3:36 am

Post by fuhrer »

i dont understand
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

fuhrer wrote:i dont understand
Either read again or tell us what part you don't understand...
Image
fuhrer
Captain
Posts: 253
Joined: Sun Mar 14, 2004 3:36 am

Post 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?
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

nope

Post 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
Tom Trude,

Image
Post Reply