variables from one map script to another

Post your scripting questions / solutions here

Moderator: Moderators

m4rine
Major General
Posts: 714
Joined: Fri Apr 11, 2003 5:28 pm
Location: UK

variables from one map script to another

Post 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!
"We must become the change we want to see in the world" (Mahatma Gandhi)
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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"
Image
m4rine
Major General
Posts: 714
Joined: Fri Apr 11, 2003 5:28 pm
Location: UK

Post by m4rine »

thanks

and then would i be able to use the variable in conditionals and 'if' statements and stuff?
"We must become the change we want to see in the world" (Mahatma Gandhi)
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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.
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Cant see why not... try it.
Admin .MAP Forums
Image
Head above heels.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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)
Image
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post by omniscient »

off topic, i forgot u need two = signs for a =. saves me a post, thanks.
vonderbakluft
Corporal
Posts: 46
Joined: Fri Aug 01, 2003 11:15 am
Location: NL
Contact:

Post 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
Real mappers map in wordpad ;-)
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post by omniscient »

i made a box in word pad, radiant is easier.
m4rine
Major General
Posts: 714
Joined: Fri Apr 11, 2003 5:28 pm
Location: UK

Post 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.
"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:

Post 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...
Admin .MAP Forums
Image
Head above heels.
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post 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 :D
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

Post by omniscient »

nuggets, i hate to tell ya, but notepad does that too.
vonderbakluft
Corporal
Posts: 46
Joined: Fri Aug 01, 2003 11:15 am
Location: NL
Contact:

Post by vonderbakluft »

LOL. Calm down m8s.

Never knew that my sig once should be taken serious.

However i like the forum post idea :wink:

Von
Real mappers map in wordpad ;-)
m4rine
Major General
Posts: 714
Joined: Fri Apr 11, 2003 5:28 pm
Location: UK

Post 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
"We must become the change we want to see in the world" (Mahatma Gandhi)
Post Reply