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
helloworld
Newbie


Joined: 21 Apr 2005
Posts: 5

PostPosted: Thu Apr 21, 2005 8:15 am   

#if !%ismember doesn't work the way I want it to
 
Hello.
I'm trying to create a variable with stringlist. For some reason it doesn't work the way I want it to.

Code:

#trigger {^(*) casts '(*)' ~((*)~)}
#va whowascaster "%1"
#va whatwasspell "%3"

#if !%ismember( @whatwasspell, @whowascaster) {#va @whowascaster %additem( @whatwasspell, @whowascaster)}


It succesfully creates a variable with parsed @whowascaster but it has parsed value of @whowascaster and @whatwascast like this:
variable: helloworld value: helloworld|magic missile

And this is what I want it to look like:
variable: helloworld value: magic missile

And if I then happen to cast fireball, the variable would look like this:
variable: helloworld value: magic missile|fireball

Currently it just changes the latter string to what was the latest spell, like this:
variable: helloworld value: helloworld|fireball

What I'm trying to do is create a 'database' that has a list of all the spells people are able to cast.

I tried for test to do it like this:
Code:

#trigger {^helloworld casts '(*)' ~((*)~)}
#va whatwasspell "%3"

#if !%ismember( @whatwasspell, helloworld) {#va helloworld %additem( @whatwasspell, helloworld)}

That worked fine, I got a variable helloworld with correct stringlist
variable: helloworld value: magic missile|fireball

How could I accomplish this?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Apr 21, 2005 10:10 am   
 
If I am following this right you are capturing player names and spells cast. You are then looking to create/update variables that have a name matching the player name with the list of spells you have seen them cast. Again if I am right then what you are looking for is a level of indirection. To further shorten this I will use the #ADDITEM command as it automatically eliminates duplicates.

#trigger {^(*) casts '(*)' ~((*)~)} {
#va whowascaster "%1"
#va whatwasspell "%3"
#ADDITEM @whowascaster {@whatwasspell}
}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
helloworld
Newbie


Joined: 21 Apr 2005
Posts: 5

PostPosted: Thu Apr 21, 2005 4:11 pm   
 
That seems to work great, thank you!

On a related note, is it possible to search variables.
Like, if I don't remember who I am, could I do something like /find hello which would search variables in specific class and return all matches to hello.

Like this:
#find caster hello
where #find would be the command, 'caster' would be the class folder and 'hello' would be a part of the word I'm searching for.
returns:
helloworld magic missile|fireball
helloearth magic missile|melfs acid arrow
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Apr 21, 2005 9:29 pm   
 
There is nothing I know of to do that. However you can use the Settings Editor to display only Variables in a specific class or all classes and sort them by name.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
helloworld
Newbie


Joined: 21 Apr 2005
Posts: 5

PostPosted: Tue May 03, 2005 3:30 pm   
 
Sorry to dig this thread back up.

It seems that adding a value to a variable bugs when there are more than one word in it. Eg. #va hello world acid arrow would produce variable 'hello' with values 'world|acid arrow', and it will not capture additional spells cast, but rather change the value already existing.

I tried to do '#additem "@whowascaster" {"@whatwasspell"}' but appearantly it won't parse them anymore and rather shows the values as @whowascaster and @whatwasspell instead of 'helloworld' and 'magic missile'.

How do I fix this? :)
Reply with quote
DeReP
Adept


Joined: 14 Jun 2003
Posts: 222
Location: Chile

PostPosted: Tue May 03, 2005 4:41 pm   
 
If you add an item to a variable, with a variable that already has more than one item, the resulting variable will contain 1 item, with all the items in the added variable like this
#ADDITEM whowascaster @whatwasspell
would leave the variable like this
Whowascaster = (world|acid arrow)


#ADDITEM whowascaster "@whatwasspell"
That shouldnt leave both items with the () but both alone each like this
Whowascaster = world|acid arrow
Reply with quote
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Tue May 03, 2005 9:31 pm   
 
If I understand your problem correctly, the problem being that your variable name will sometimes be more than one word, then this should work:

#ADDITEM %replace(@whowascaster, " ", "") {@whatwasspell}

This should get rid of any spaces in the @whowascaster variable, making it "helloworld" rather than "hello world". Or, as an alternate, you could change the way the variable is captured. If you're using Vigilante's script, just change the

#VA whowascaster "%1"

to

#VA whowascaster %replace("%1", " ", "")

This is of course if I'm understanding your problem correctly, ignore me if I misinterpreted what you said.
_________________
Everyone is entitled to their beliefs - until they die. Then only the truth matters.
Reply with quote
helloworld
Newbie


Joined: 21 Apr 2005
Posts: 5

PostPosted: Wed May 04, 2005 7:20 am   
 
Yes, that's excatly what I meant Aarlot.

Thanks, I'll try it that way.
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