tandonmiir Newbie
Joined: 08 Oct 2008 Posts: 2
|
Posted: 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. |
|