Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Jan 25, 2002 12:32 am   

Using #ADDITEM to add variables?
 
Ok Im trying to make a alias that add a variable to the stringlist as is.

#ALIAS {statapp} (#ADDITEM stats ~@%1}

is what i have, and it sends what ought to be the variable to the stringlist, but it just turns out to the word @variable, ie, if i use the stringlist for a trigger, it returnd the varable name rather than the value.I had it configured so that it would record the values, however all the values of the variables that are suppose to go into the stringlist are just 1's and 0's, so I cant use %additem for just the values.Any suggestion?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Jan 25, 2002 2:18 am   
 
quote:

Ok Im trying to make a alias that add a variable to the stringlist as is.

#ALIAS {statapp} (#ADDITEM stats ~@%1}

is what i have, and it sends what ought to be the variable to the stringlist, but it just turns out to the word @variable, ie, if i use the stringlist for a trigger, it returnd the varable name rather than the value.I had it configured so that it would record the values, however all the values of the variables that are suppose to go into the stringlist are just 1's and 0's, so I cant use %additem for just the values.Any suggestion?




So you want a stringlist of 1's and 0's, as determined by what variables are added?

Simply use %additem(). It's what it's been designed for. #ADDITEM will do a similar thing, but will not create duplicates.

If you want to add the contents of the variable to stats using #ADDITEM, however, you don't need to quote the @.

li'l shmoe of Dragon's Gate MUD
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Jan 25, 2002 2:32 am   
 
ok, the reason im using #ADDITEM is because i dont want it to make duplicates of the values, because they are ever changing 1's and 0's.I cant use %additem because it will make a meaningless string of 1's and 0's.Understand?Example time.

If i have, say 3 variables(@him,@her,@it)and there are 2 set values for said variables(1 and 0)and i want a trigger or alias to add one of those variables to a stringlist(them)at any given time(maybe even a couple of times for safe measure)and then i have a script that is suppose to make sense of all the variables in the stringlist, according to its current values. Get the idea?

I was thinking maybe i could make use of the %concat fucntion, but the help file says that it only hold 9 parameters, and i need like 50 or so.... anyways, thanks for the speedy reply, please do it again :P
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Jan 25, 2002 2:57 am   
 
Ok, I think I know where you're going with this.

You want a data structure to keep track of various stats of the character like 1|1|0|1|0|1|1|..., with each element always corresponding to a particular stat.

I say drop the simple stringlist and go with a data record variable. it's like a stringlist with a little something extra.

stats.hungry = 1
stats.thirsty = 0
stats.wounded = 1
(etc)

You won't even need to worry about #ADDITEM because you can simply set these element fields directly in your code, like a variable:

stats.hungry = 0
eat fish

li'l shmoe of Dragon's Gate MUD
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Jan 25, 2002 2:59 am   
 
To be more specific let me show you the script and what im trying to do.

#Al {castall} {#IF {@spuplvl>=@armorlvl} {c0 armor}

that is my spellup script, the it checks it see if if im the apporiate lvl to cast the spell, then it checks to see if @armor=1(true)or 0(false), before finally casting on me. If been trying for the last 13hrs to figure out how to put append something so that it will put the value of @1 into my status line.I figured this could be done with stringlist like so:

#AL {castall} {#IF {@spuplvl>=@armorlvl}} {c0 armor;#ADDITEM statvar @armor}

and then make a status line with @statvar in it....no go.So then i was trying what you see above by simply doing:
#AL {castall} {#IF {@spuplvl>=@armorlvl} {c0 armor;statapp @armor}//or just armor.
and that doesnt work either.I was trying other things to,with %additem and %expand, but it always does one of 2 things, either my status line acually contains the variable names(via #ADDITEM) or it contains a string of meaningless 1's and 0's(via %additem, because of the frequency that i check the expressions).

Any suggestions,short of rewriting my entire script, are welcome :)

EDIT:was writing this when you posted Matt, Ill give that a try and see what i can get from it.Thanks :)
dacheeba
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: Fri Jan 25, 2002 3:18 am   
 
In zMUD, 0 is false, non-zero values are true. Why not just assign 1 or 0 to @armor. I'm not even clear on how you'd assign anything to @1.

#Al castall {#IF ((@spuplvl>=@armorlvl) & !@armor) {c0 armor; #VAR armor 1}

#TR {Whoa dude, your armor spell wore off} {#VAR armor 0}

Troubadour
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Fri Jan 25, 2002 3:52 am   
 
Just a little note on the comment you made about %concat. This seems to be an old limitation that hasn't been updated. %concat will work with more than nine parameters.

Kjata
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Jan 25, 2002 4:15 am   
 
quote:

In zMUD, 0 is false, non-zero values are true. Why not just assign 1 or 0 to @armor. I'm not even clear on how you'd assign anything to @1.

#Al castall {#IF ((@spuplvl>=@armorlvl) & !@armor) {c0 armor; #VAR armor 1}

#TR {Whoa dude, your armor spell wore off} {#VAR armor 0}

Troubadour


Not sure why you think I have @1 in my script, but my script is set up simular to how you mention. I have 2 seperate triggers that assign the values to @armor.ie
#tr {you feel someone protecting you} {#var armor 1}and
#tr {you feel your protection slip away} {#var armor 0}
then i have the c0 aliased to if @%1=true then cast %1, and thats nested in the castall alias, so it wont fire unless im the appropriate lvl for the spell.Mainly I start this tread to get the status line populate with my current script intact, as it works beautifully,but i dont want the spells to be in the status line unless i can cast them, so it doesnt cluter it.Does that make any sense?So, I have problems conveying my thoughts :P
dacheeba
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Jan 25, 2002 5:09 pm   
 
ok, been working with these data records, but i cant get it to return the values, im not sure im using the correct commands/functions but this wont work

test.stattest = 1
test.statest = 0

now i can put this in a @mytest:
%db(test,stattest)
%db(test,statest)
and put @mytest into my status line, but it will only return the last given record in @mytest, instead of both? what do i do here?
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Jan 25, 2002 7:10 pm   
 
ok, i think i am pretty confident that i can do this with data records, but i need a way that i can return all the values, with out returning the names.Even better would be a way i could return all the values indivually, and be able to put them all into a seperate variables using my cureent nested if's.Ive played aroung with the %db,%iskey,#LOOPDB commands and soaked up every help file I can on the subjects, and just cant get it to work. when i do this

#VAR test {teststat = 1|teststuff = 0| teststu =1}
#VAR mytest {%iskey( @test, teststuff);%iskey( @test, teststu);%iskey( @test, teststat)}
#ST @mytest
all it does is returns the value of @test.teststat, and not the other 2...Someone please enlighten me as to what I am doing wrong?Thanks.
dacheeba
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Jan 25, 2002 7:17 pm   
 
#VAR mytest {%db(@test,stattest)%db(@test,statest)}

Tested and worked fine for me. Note the use of the @ symbol and that I just ran everything together inside braces.


LightBulb
All scripts untested unless otherwise noted
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Jan 25, 2002 8:44 pm   
 
great that does it Lightbulb, Thanks a bunch for all your help guys :)
dacheeba
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net