Full Version : SETVAR + GETVAR
xmlspawner >>Q&A >>SETVAR + GETVAR


<< Prev | Next >>

olsyke- 06-16-2006
hi all of you smile.gif

what i am tryin at the moment is building a Flying Carpet sololy from XMLSpawner ingame smile.gif


made some good progress so far but theres something blockin my way ....

CODE
IF/{GETVAR,Pilot1},Direction=North/11


CODE
IF/GETVAR,Pilot1,Direction= North/11


CODE
IF/{GETVAR,Pilot1},playermobile,Direction= North/11



and that is the bugger... tried it several ways but all i get is stuff like::

Direction:

GM (myname),playermobile,Direction:


then i also tried Redefining the VARIABLE as the 2nd Entry of that Spawner but diddnt change anything tho....



funny thing i noticed... i changed my name in the Book and on my Character but the spawner keeps saying he cant find me with the previous name



well... any ideas would be welcome













ArteGordon- 06-16-2006
how and where are you setting the Pilot1 local variable with the SETVAR keyword?

olsyke- 06-16-2006
well

First thing i tried was defineing the Variable in a Spawner called....



Pilot

CODE
1 SETVAR,Pilot1/[GET,Pilot,Basebook,Author}
2 SETONMOB,{GETVAR,Pilot},Playermobile/location/GET,FlyingCarpet,Xmlspawner,Location



wich is dedicated to keeping the Rider on its Carpet.. works perfectly

and here comes what involves the Directing of the Carpet and where my problem hides



DirectionController

CODE
(0 SETVAR,Pilot1/[GET,Pilot,Basebook,Author}//tried defining the variable here aswell with no luck//))

1   IF/{GETVAR,Pilot},Direction=North/11
1   IF/{GETVAR,Pilot},playermobile,Direction=SOUTH/12
1   IF/GETVAR,Pilot,playermobile,Direction=East/13
1   IF/{GETVAR,Pilot},playermobile,Direction=West/14
11 SETVAR,Direction/{y/INC,-}
12 SETVAR,Direction/{y/INC,}
13 SETVAR,Direction/{x/INC,-}
14 SETVAR,Direction/{x/INC,}



*EDIT* the entrys on SUB 1 varry because i tried several ways


well thats how far i made it besides a few other spawners with stuff that doesnt matter to this issue

ArteGordon- 06-17-2006
so I assume that this is going to set the 'Pilot1' local variable to the name of the player that you want to change the direction of.

SETVAR,Pilot1/{GET,Pilot,Basebook,Author}

Then, when you want to refer to the Direction property on that named player that you would normally use the GETONMOB keyword

GETONMOB,mobname[,mobtype],property

to do something like

IF/GETONMOB,playername,PlayerMobile,Direction=#North/12

but you want to substitute the value of Pilot1 for the playername string, so you would use the GETVAR keyword and the substitution brackets {} like

IF/GETONMOB,{GETVAR,Pilot1},PlayerMobile,Direction=#North/12

I'm not sure what you intended to do here

SETVAR,Direction/{y/INC,-}

olsyke- 06-17-2006
CODE
1   IF/{GETVAR,Pilot},Direction=North/11
1   IF/{GETVAR,Pilot},playermobile,Direction=SOUTH/12
1   IF/GETVAR,Pilot,playermobile,Direction=East/13
1   IF/{GETVAR,Pilot},playermobile,Direction=West/14


well these would be to Check where the player is facing towards so.....

for example if the player was facing north ->goto sub 11


--> 11 SETVAR,Direction/{y/INC,-}


this is what i figured could work to control the throttle and the direction at once like-->


SET,FlyingCarpet,XmlSpawner/{GETVAR,Direction}{GETVAR,SPeed}

wich would basicly result in --> SET,FlyingCarpet,XmlSpawner/y/INC,-3 -->


what means flying north right ?


atleast i hope so tongue.gif

ArteGordon- 06-17-2006
ah ok, yeah so you want to set the Direction local variable (which is a string), like this

SETVAR,Direction/@y/INC,-

which uses the literal-to-end-of-line operator @ to set Direction to the string 'y/INC,-'
If you didnt use that, then it would try to parse the special chars in there like the '/'

olsyke- 06-17-2006
hm very well guess you saved my day again smile.gif


just one more question... does it matter at all where (on what spawner) i declare variables ?

and what happens if 2 or more Vars have the same name ?




*EDIT* ahhh and another one ^^ -->

I
CODE
IF/GETONMOB,{GETVAR,Pilot1},PlayerMobile,Direction=#North/12



whats that # in front of "north" for ?


ArteGordon- 06-17-2006
North is an enum value. The # tells it to treat it as an enum instead of as a variable name.
This is from the Howto section on conditional tests.
http://xmlspawner.15.forumer.com/index.php?showtopic=399

olsyke- 06-17-2006
damn straight how could i have missed that link !!

well well i guess i owe you to release this here when im done with it smile.gif

olsyke- 06-18-2006
hmm im still having a problem here


CODE
1 SETVAR,Pilot1/{GET,Pilot,Basebook,Author)
2 IF/GETONMOB,{GETVAR,Pilot1},PlayerMobile,Direction=#North/11
2 IF/GETONMOB,{GETVAR,Pilot1},PlayerMobile,Direction=#South/12
2 IF/GETONMOB,{GETVAR,Pilot1},PlayerMobile,Direction=#East/13
2 IF/GETONMOB,{GETVAR,Pilot1},PlayerMobile,Direction=#West/14
GOTO/2
11 SETVAR,Direction/@y/INC,-
12 SETVAR,Direction/@y/INC,
13 SETVAR,Direction/@x/INC,
14 SETVAR,Direction/@x/INC,-




this spawnere here never leaves Sub2 for me... Altough i am Author of the Book

must be still something wrong with the IF lines

ArteGordon- 06-18-2006
Check the value of Pilot1. It has to match your name exactly, with capitalization and spaces.
You can either add a spawn entry to display it or just look at the attachments on the spawner. That is where those local variables are stored.

olsyke- 06-18-2006
okay just figured how to check the attachments

the Variable Pilot has the correct name in "data"
but ill keep on searching for errors

still every idea is welcome

olsyke- 06-22-2006
well this diddnt work out for me after all and i ran into the same issue with another important project....



... how big is the chance that this is because the xmlspawner version is only 3.03 ?

ArteGordon- 06-22-2006
there was a change to GETVAR added in v3.08 to fix an issue with xmldialogs not having access to their value, but I dont know if it would have had any effect on spawner use of GETVAR. I will see if I can reproduce your problem.