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
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Wed Dec 13, 2006 5:55 pm   

Capturing multiple items from lists
 
The following information is output from the mud I want to know if/how

1st I can capture the information to be allowed to work with it?
2nd See if things are not there?

1. I get 2 or 3 lists like the following

1020h, 1020m e-
"witan115996": x2 A witan leaf. Prepared
"denallo116089": x2 Some denallo bark. Prepared
"kathkusa116114": x2 A kathkusa leaf. Prepared
"lestagii116116": x2 A lestagii berry. Prepared
"courgia116126": x1 Some courgia fluff. Prepared
"aldaka116131": x2 An aldaka root. Prepared
"siriena116132": x2 A siriena petal. Prepared
You hold, in your hands, 13 batches.

can I capture this into some variables eg @witan lets say to contain how many i am holding eg (x2)

also if something is missing eg here I am not seeing any eg (athillias)

Thanks hope thats sort of clear ?

I get this list by typing "herblist" and the capture should stop on "You hold, inyour hands, (%d) batches.

Stark62
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed Dec 13, 2006 11:06 pm   
 
Code:
#CLASS {herblist}
#ALIAS herblist {
  #T+ herblist {TRIGGER}
  herbs = ""
  ~herblist
  }
#VAR herbs {}
#VAR herblist {fred|bob|witan|denallo|kathkusa|lestagii|courgia|aldaka|siriena|athillias}
#TRIGGER "herblist" {^~"%a~": x(%d) {A|An|Some} (%w) {leaf|bark|berry|fluff|root|petal}. Prepared$} {#addkey {herbs} {%2} {%1}} "" {disable}
#TRIGGER {You hold, in your hands, (%d) batches.} {
  herbtemp = @herblist
  #LOOPDB @herbs {#DELITEM herbtemp %key}
  #SAY Missing Herbs: %expandlist( @herbtemp, ", ")
  #T- herblist {TRIGGER}
  }
#CLASS 0


Should get you started.
It captures all the herbs you're carrying into a key/record variable, then it compares the herbs you have against a master list and tells you anything that you don't have that exists in the master list.

Guinn
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Thu Dec 14, 2006 12:23 am   
 
Perfect

Dont know the cure for bob but hey ;)

thanks again
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Thu Dec 14, 2006 12:45 am   
 
maybe found a problem

when i type herblist there is no actual trigger ?

by typing herblist I want it to start
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Dec 14, 2006 12:57 am   
 
The script above creates a trigger with the ID "herblist" and then uses the #T+ command to activate it before running the command. The trigger should exist but be disabled after entering Guinn's script above (you just need to paste it onto the command line).
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Thu Dec 14, 2006 12:58 am   
 
Quote:
when i type herblist there is no actual trigger ?

Not sure what you mean

herblist is just an alias that just enables the trigger and clears the current herbs you have
each line then populates the 'herbs' variable, and when it sees the last line it tells you what you don't have

Quote:
by typing herblist I want it to start

want what to start?

Guinn

edit: Ahh, think Fang might've understood your post better and answered the question
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Thu Dec 14, 2006 1:20 am   
 
I pasted it as you said

I type herblist and get


970h, 970m e-
"witan80463": x4 A witan leaf. Prepared
"aldaka58840": x4 An aldaka root. Prepared
"lestagii77110": x4 A lestagii berry. Prepared
"athillias37181": x3 An athillias leaf. Prepared
"denallo54371": x1 Some denallo bark. Prepared
"kathkusa91124": x4 A kathkusa leaf. Prepared
You hold, in your hands, 20 batches.
Missing Herbs: fred, bob, witan, denallo, kathkusa, lestagii, courgia, aldaka, siriena, athillias
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Thu Dec 14, 2006 1:41 am   
 
ok i got this

in a Class folder called herblist

alias name herblist
alias value #T+ herblist {TRIGGER};herbs = "";~herblist

Var name herblist
Var value fred|bob|witan|denallo|kathkusa|lestagii|courgia|aldaka|siriena|athillias

Var name herbs
Var value

trig pattern You hold, in your hands, (%d) batches.
trig value herbtemp = @herblist;#LOOPDB @herbs {#DELITEM herbtemp %key};#SAY Missing Herbs: %expandlist( @herbtemp, ", ");#T- herblist {TRIGGER}

trig pattern ^~"%a~": x(%d) {A|An|Some} (%w) {leaf|bark|berry|fluff|root|petal}. Prepared$
trigvalue #addkey {herbs} {%2} {%1}


and then in no class I have

Var name herbtemp
var value fred|bob|witan|denallo|kathkusa|lestagii|courgia|aldaka|siriena|athillias

? stark62
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Dec 14, 2006 1:45 am   
 
That's right. So what did you mean by there being "no actual trigger"?
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Thu Dec 14, 2006 7:05 am   
 
Sorry I first misunderstood when i read #T- herblist {TRIGGER} I thought it meant that I needed a trigger for herblist. That is not my problem my problem is with the above script I get the answer in post "I pasted it as you said" above?

ie all the herbs say they are missing when clearly they are not.

stark62
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Dec 14, 2006 10:35 am   
 
Looks like the pattern isn't matching. Change:
trig pattern ^~"%a~": x(%d) {A|An|Some} (%w) {leaf|bark|berry|fluff|root|petal}. Prepared$
to
trig pattern ^~"%w~": x(%d) {A|An|Some} (%w) {leaf|bark|berry|fluff|root|petal}. Prepared$
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Thu Dec 14, 2006 11:41 am   
 
Changing %a to %w wouldn't help Vij, since the pattern is abc123 then %w wouldn't match - needs to be alphanumeric %a

The problem looks like the trigger isn't being enabled properly. I've just removed the lines that disable it so it'll always fire. Also, I moved the herbtemp variable inside the class to keep things tidy.
Code:
#CLASS {herblist}
#ALIAS herblist {
  herbs = ""
  ~herblist
  }
#VAR herbs {}
#VAR herbtemp {}
#VAR herblist {fred|bob|witan|denallo|kathkusa|lestagii|courgia|aldaka|siriena|athillias}
#TRIGGER "herblist" {^~"%a~": x(%d) {A|An|Some} (%w) {leaf|bark|berry|fluff|root|petal}. Prepared$} {#addkey {herbs} {%2} {%1}} ""
#TRIGGER {You hold, in your hands, (%d) batches.} {
  herbtemp = @herblist
  #LOOPDB @herbs {#DELITEM herbtemp %key}
  #SAY Missing Herbs: %expandlist( @herbtemp, ", ")
  }
#CLASS 0

When adding scripts all you need to do is copy everything above and paste it into the command line, then press return. zMUD will create the class and put all the aliases and triggers inside. So no need to create each trigger and alias manually and copy/paste things in one at a time.

After adding the code then pasting in
Quote:
970h, 970m e-
"witan80463": x4 A witan leaf. Prepared
"aldaka58840": x4 An aldaka root. Prepared
"lestagii77110": x4 A lestagii berry. Prepared
"athillias37181": x3 An athillias leaf. Prepared
"denallo54371": x1 Some denallo bark. Prepared
"kathkusa91124": x4 A kathkusa leaf. Prepared
You hold, in your hands, 20 batches.

the script returns
Missing Herbs: fred, bob, courgia, siriena

Which should be correct.
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Thu Dec 14, 2006 3:41 pm   
 
ok calmed down ;)

when i looked at this in editor it says there is a syntax error at the {#delitem
under the # if i remove that it then jumps tp ;#say again under the # in the following pattern created by pasting the above

trig You hold, in your hands, (%d) batches.
pattern herbtemp = fred|bob|witan|denallo|kathkusa|lestagii|courgia|aldaka|siriena|athillias;#LOOPDB {#DELITEM herbtemp %{key}};#SAY Missing Herbs:

not sure if that tells you anything but seems thats where the problem is

thanks

Stark62 (computers made me bald)
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Fri Dec 15, 2006 10:08 am   
 
seems to say that an "argument expected" at the {#DELITEM

it points to the # if i alter then it jumps to the #say also

tried to alter it with a load of stuff but nothing happening all other script lines seem to be accepted

thanks as always

Stark62
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Fri Dec 15, 2006 10:35 am   
 
Hmm, not sure what to say. It works fine for me. To be sure, I deleted all the settings reopened zMUD, hit escape at the character select to go to the untitled session, then pasted in the code from my last post, checked the settings editor, where everything was properly created with no syntax errors.

Then I pasted in the bit of text to test with and it populated the variables correctly and came back with the same result as before.
Even tried it in the public release of CMUD and it works fine there too.

Have you tried the script with a new .mud file yet, or when using the offline untitled one (where you hit escape on the char select screen in zmud)
If so, could you post a screenshot of the trigger that's having syntax errors.

Cheers
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Fri Dec 15, 2006 10:51 am   
 
erm how do i post image ... it wont paste in here and if i use reply it wants an http adress .... do i need to post it somewhere as i cant see an email adress to post it too

thanks
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Fri Dec 15, 2006 11:14 am   
 
got screenshot as a jpeg how can i post it (wont post on here) do i need to put it somewhere on web or post it to you?
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Fri Dec 15, 2006 11:23 am   
 
imageshack.us allows free hosting
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Fri Dec 15, 2006 12:21 pm   
 
http://img147.imageshack.us/img147/8666/screenshot1uc4.jpg
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Fri Dec 15, 2006 1:57 pm   
 
Odd, I don't know why the trigger doesn't have the right value associated.
Replace what's in that trigger action with

herbtemp = @herblist
#LOOPDB @herbs {#DELITEM herbtemp %key}
#SAY Missing Herbs: %expandlist( @herbtemp, ", ")
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Fri Dec 15, 2006 2:46 pm   
 
Nope is this right (just checking through as much as i can

if it is what does it do - trying to learn this?

abc herblist
value herbs = "";~herblist
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Fri Dec 15, 2006 2:52 pm   
 
the 'abc' icons are aliases

herbs = "";~herblist

is two commands
first one: herbs = ""
which is just making the value of the herbs variable empty

second one: ~herblist
which sends the command herblist to the game
you have to put ~ before it otherwise it'll call itself (since the alias is also called herblist) and enter an infinite loop

Don't worry about the alias though, that's working fine. It's the highlighted trigger that's causing the problem.
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Fri Dec 15, 2006 2:59 pm   
 
Ahh, I know what's gone wrong... it's a setting inside preferences that's messing up how the scripts are entered on the command line.

Okay, the fix is...
View -> Preferences -> General
Then select 'Script Parser' and uncheck 'Expand Vars'



Click okay, then try pasting in the script again

The problem was that when variables were being expanded on the command line then the line
herbtemp = @herblist

was messing up, because herblist was bob|fred|...
and that was messing up the syntax
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Fri Dec 15, 2006 4:47 pm   
 
would love to say it fixed it but unfortunately it didnt

my settings where the same as yours

it seems the herb variable is getting nothing in it at all when i run the script
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Fri Dec 15, 2006 6:52 pm   
 
So when you correct the value of the trigger it still doesn't work?

If not I'm out of ideas I'm afraid. The script works. It's a setting somewhere in zMUD that's expanding variables.
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
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