Page 1 of 2
variables from one map script to another
Posted: Tue Dec 30, 2003 8:56 pm
by m4rine
is it possible to pass variables form one map's script to another map's script?
for example if i set a variable $example in example_map.scr, would there be a way to pass on the variable to the next map (which will be auto-loaded when the level is finished) and use it in example_map_2.scr?
i know that in other scripting languages (such as c++ and PHP) you would use the GET and POST methods but i doubt whether you would use these in game scripting.
any help would be very much appreiciated!
Posted: Tue Dec 30, 2003 9:11 pm
by jv_map
You could stash it in a cvar:
map 1:
Code: Select all
setcvar "example1" level.example1
map2:
Code: Select all
level.example1 = getcvar "example1"
Posted: Tue Dec 30, 2003 9:37 pm
by m4rine
thanks
and then would i be able to use the variable in conditionals and 'if' statements and stuff?
Posted: Tue Dec 30, 2003 11:40 pm
by bdbodger
could you do game.var = 1 ?
in scripts.txt it says :
Predefined object references
============================
1) game
Refers to the unique game object which maintains its state across levels. Only primitive values (integers/floats/strings/vectors) will persist across levels.
2) level
Refers to the unique level object which maintains its state for the duration of a level.
3) local
Refers to the thread executing the current command.
4) parm
Refers to the unique parm object which can be used to pass parameters to new threads.
Note that any use of this variable could be coded "better" by using parameters in the creation of new threads.
5) self
Refers to the object that the thread is processing for. This object is the same for all threads in a group of threads.
6) group
Refers to the object representing the group of threads the thread executing the current command belongs to.
Posted: Wed Dec 31, 2003 1:14 am
by Bjarne BZR
Cant see why not... try it.
Posted: Wed Dec 31, 2003 7:48 am
by jv_map
I never had any luck with 'game.'
Note that the setcvar and getcvar way automatically casts the variable to a string, so you'd have to type:
if(level.example1 == "1")
Or, you could change this line
level.example1 = getcvar "example1"
to
level.example1 = int (getcvar "example1" )
and then use
if(level.example1 == 1)
Posted: Thu Jan 01, 2004 5:58 am
by omniscient
off topic, i forgot u need two = signs for a =. saves me a post, thanks.
Posted: Thu Jan 01, 2004 11:57 am
by vonderbakluft
game. vars work for transferring values (but not complex stuff like objects) from one bsp to another. I usually do this
<at end of bsp 1>
game.myvar = level.myvar
<bsp 2 before level.waittill spawn>
level.myvar = game.myvar
level wattill spawn
.... and now further using level.myvar again
Success
Von
Posted: Fri Jan 02, 2004 2:48 am
by omniscient
i made a box in word pad, radiant is easier.
Posted: Sun Jan 04, 2004 9:12 pm
by m4rine
vonderbakluft's sig wrote:Real mappers map in wordpad
oh and i suppose you opened up wordpad, created your own PHP that interacts with .map's mysql, embedded it in your own HTML, then hacked into the PMOH server and uploaded the files through MS-DOS? Then you would be a 'real' forum poster.
but seriously, what is your definition of a 'real' mapper? And if you had any sense you would use notepad not wordpad because wordpad can format text - making it quite annoying with copy+paste and other text functions. If you had any sense you would use notepad - no formatting, just plain text.
Posted: Mon Jan 05, 2004 12:24 am
by Bjarne BZR
vonderbakluft's sig wrote:Real mappers map in wordpad
I mostly write the BSP directly into memory with an on/off switch I conneted to a COM port... you can skip the operating system all together that way. But I wrote a little OS just to write the BSP to disk every now and then.
And this is not me writing, It't a very small shell script I replaced myself with because I was way to un-effective to be allowed to fiddle around with such expensive hardware as this computer.
Off topic? Eh... probably... I was bored...
Posted: Mon Jan 05, 2004 12:29 am
by nuggets
ermmm... surely "real mappers" wouldn't use either they'd just use radiant or a specific engine to do the job needed to be done,
a real mapper is probably someone who gets paid lots of money for making maps, and therefore would have nothing to do with scripting
but wordpad is better than notepad, there are options to turn off all formatting, has a lot more functions and has all the shortcut keys enabled, which is any SCRIPTERS happiness, scripters don't want to bother with the mouse having to click on save everytime, let CTRL + S do the job
(and yes i know you can use ALT + F, S)
replace... ever needed to change the name of a targetname, and then had to find each instance of it in the script?
drag options... save cutting and pasting incase something is stored in the clipboard, just drag it where you want to
etc... etc...
so in summary
always use wordpad, unless you a real mapper, then don't use either

Posted: Mon Jan 05, 2004 2:29 am
by omniscient
nuggets, i hate to tell ya, but notepad does that too.
Posted: Mon Jan 05, 2004 11:57 am
by vonderbakluft
LOL. Calm down m8s.
Never knew that my sig once should be taken serious.
However i like the forum post idea
Von
Posted: Tue Jan 06, 2004 3:01 pm
by m4rine
lol i am truly very sory, i was v sharp, need more sleep. it was more ment as a joke but sleep, i need more of it, it makes me grumpy lol