local/level/game

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

local/level/game

Post by SilentAngel »

I know that if I whatn't to pass a local.variable already initialized to a method I have to do that:

Code: Select all

...
...
thread mymethod local.variable

mymethod local.variable:
...
...
becouse if I just do thrad myvariable, the local.variable i have in my method is not the same, so I cannot use it...but...my question is:
I have to do that with level and game variables?
isn't there a way to do that? becouse I'm having problems with a scr and I think it's becouse I don't pass level var as I do in local var...
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

What do you mean, 'is not the same'? That's impossible, the variabled you passed on as an argument must be the same in the other thread even if you renamed the variable.

What, exactly are you trying to accomplish? I may be reading your post wrong but you say you do not pass on a variable, you just thread, well then obviously the argument is NIL.
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

ok..I'll make some exemples:

that works:

Code: Select all

main:
local.myvariable = 8
thread print local.myvariable
end

print local.myvariable:
iprintf ("my variable is " + local.myvariable)
end
but I'm asking if I have to do that with level variables..
in other worgs..I'm asking if something like that works:

Code: Select all

main:
level.myvariable = 8
thread print
end

print:
iprintf ("my variable is " + level.myvariable)
end
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Yes.

Local variables are only defined within threads (ie. between a label and the 'end' command). However they can be passed on as arguments to other threads. The 'end' command actually 'deletes' the scriptthread (since it's a class and it has to be "spawned", so to speak.) And also uninitializes all local variables. Since local variables are in fact 'properties' of the scriptthread. Jv knows more about this and parm.previousthread.

Group variables are defined in threadgroups and do survive end commands. However if the end marks the last thread in the group then they get killed.
A threadgroup is this:

Code: Select all

main:
//blah...
level waittill prespawn
//blah...
level waittill spawn

thread mythread1
end

mythread1:

group.var = 1
println group.var

thread anotherthread
end

anotherthread:

println group.var

end // the group of threads ends here since no other thread gets activated.
Even multiple activated threads are all part of a group:

Code: Select all

mythread:

group.var = "lol"
println group.var

thread t1
thread t2
end

t1:
println group.var
end

t2:
println group.var
thread t3
end

t3:
println group.var
end
Level variables as the name suggests are 'levelwide'. Meaning they get 'killed' when the round/map ends.

Game vars are map-persistent (in regular cases, for some reason roundrestarts and maprestarts kill them) meaning game.var = 1 in mohdm1 will stay 1 when the map changes to mohdm2. However this only works for simple values such as arrays, integers, floats, strings...
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

ok ty man..
Post Reply