variables from one map script to another
Moderator: Moderators
variables from one map script to another
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!
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!
"We must become the change we want to see in the world" (Mahatma Gandhi)
You could stash it in a cvar:
map 1:
map2:
map 1:
Code: Select all
setcvar "example1" level.example1
Code: Select all
level.example1 = getcvar "example1"
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.
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.
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
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)
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)
-
omniscient
- Major General
- Posts: 694
- Joined: Tue Sep 16, 2003 12:02 am
-
vonderbakluft
- Corporal
- Posts: 46
- Joined: Fri Aug 01, 2003 11:15 am
- Location: NL
- Contact:
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
<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
Real mappers map in wordpad 
-
omniscient
- Major General
- Posts: 694
- Joined: Tue Sep 16, 2003 12:02 am
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.vonderbakluft's sig wrote:Real mappers map in wordpad
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.
"We must become the change we want to see in the world" (Mahatma Gandhi)
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
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.vonderbakluft's sig wrote:Real mappers map in wordpad
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...
-
nuggets
- General
- Posts: 1006
- Joined: Fri Feb 28, 2003 2:57 am
- Location: U-england-K (england in the UK) :P
- Contact:
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
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
hope this helps, prob not cos it's all foreign 2 me :-/
-
omniscient
- Major General
- Posts: 694
- Joined: Tue Sep 16, 2003 12:02 am
-
vonderbakluft
- Corporal
- Posts: 46
- Joined: Fri Aug 01, 2003 11:15 am
- Location: NL
- Contact:

