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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
tandonmiir
Newbie


Joined: 08 Oct 2008
Posts: 2

PostPosted: Wed Oct 08, 2008 9:44 pm   

Database Records and Parsing
 
I'm currently trying to build a dynamic spell vending system for a character on a MUD.

I've created a database record variable, @spells, that contains key strings for someone to request.
If someone matches my trigger, it parses through a comma separated list of spells they would like, checks the key values and casts any that match. Those that don't match are appended to an error string which is told to the requester.

This works fine and dandy, however, I would like the values of @spells to be parsed as if they were commands. This way certain spells could have messages, or creation spells would allow me to hand a created item over to the requester.

I ran into the first problem with this in the form of the %1 wildcard. I ran a %replace() on the database record value and replaced "%1" with the value of %1. That corrected the issue.

Now, however, the value is printed without regard to the semicolon. I cannot find a function that appropriately parses the string as if it was entered through the command line, or even the same semicolon behavior as the trigger editor itself... I've tried several and am either missing it, or do not understand how to force a string to be parsed as input in zScript.

My trigger is as follows:
Code:
$temp = %2
$temp = %replace($temp, ", ", "|")
$temp = %replace($temp, ",", "|")
#echo $temp

$err = "I don't recognize: "
$l = %len($err)
#FORALL $temp
{
  #echo %iskey(@spells, %lower(%i))
  #IF (%iskey(@spells, %lower(%i))) {#SEND %replace(%db(@spells,%lower(%i)), "%1", %1); #WAIT 500} {$err = $err + %i + ", "}
}

#IF (%len($err) > $l) {whisper %1 $err}


Example values from @spells appear as...
- cast 'continual light';get ball
- sayto %1 Heh, you asked for it.; cast 'change sex' %1
and so on.

Thank you for your time.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Oct 09, 2008 2:01 pm   
 
Try #exec
Reply with quote
tandonmiir
Newbie


Joined: 08 Oct 2008
Posts: 2

PostPosted: Thu Oct 09, 2008 4:25 pm   
 
That resolved the issue. I must have been using EXEC incorrectly when I tried it earlier.

Thank you!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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