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


Joined: 02 Jul 2002
Posts: 74
Location: USA

PostPosted: Wed Mar 17, 2004 12:21 pm   

Trigger help
 
Trying to make set of triggers for an equipment database on the mud I play on.
Having some problems with wands/staves and potions though.
Example of a potion:
You complete your spell...
You feel informed:
Object 'potion protections', Item type: POTION
Item can be worn on: HOLD
Item will give you following abilities:
Item is: MAGIC
Weight: 1, Value: 1000
Level 30 spells of:
protection from fire
protection from cold
protection from acid
Can affect you as :
Affects : SV_BREATH By -5

Example of staff/wand (they look the same when id'd)
You complete your spell...
You feel informed:
Object 'wooden staff', Item type: STAFF
Item can be worn on: HOLD
Item will give you following abilities: NOBITS
Item is: TWOHANDS
Weight: 10, Value: 2000
Has 4 charges, with 4 charges left.
Level 26 spell of:
firestorm
Can affect you as :
Affects : SV_SPELL By -2

for staves/wands, I'm able to capture everything except the type of spell. I've been trying to use a trigger like:
#TRIGGER {Level &dbItem.SpellLevel spell of:$^(*)} {#if (!%proper( %1)) {%additem( %1, &dbItem.GrantedSpells)}}

The spell names are always lowercase, hence the !%proper. The field I'm trying to populate in the database is set as text. One thing I did notice when I set this trigger up is that only the &dbItem shows up as blue while editing the trigger and the .GrantedSpells shows as black, almost like its not recognizing the whole thing as a variable.
It is capturing the spell level just fine, its just totally missing the spell name. The "Can affect you as :" and "Affects :" lines are not always there. Figure I'm just going about trying to capture it the wrong way.

Potions are almost like staves/wands except they can have between one and three spells like in the example above. They also may or may not have the "Can affect you as :" and "Affects :" lines there as well.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Wed Mar 17, 2004 12:43 pm   
 
What's happening is that %proper returns the string you give it with the first character in uppercase and the rest in lowercase. A string, in zMUD, is a valid true/false value, and since it is not an empty string, this one means true. When you negate this in the condition for the #IF in the trigger, it will always evaluate to false and the commands of the #IF will never be executed.

What you need to do is check to see if the string returned by %proper is the same as the original string:
#IF (!(%proper("%1") = "%1")) {...}

As for the color of &dbVar.key, you shouldn't worry about it. This is just how the pretty printer handles this syntax, it does not mean that it is not recognizing the part after the dot.
Reply with quote
SpiritWolf
Wanderer


Joined: 02 Jul 2002
Posts: 74
Location: USA

PostPosted: Wed Mar 17, 2004 1:06 pm   
 
Hrm.. maybe I'm just missing something then.
Tried that and it somehow ended up sending the spell level to the mud and not capturing anything. Same thing it done when I tried setting my trigger with the %additem in the false portion of the if statement.
Reply with quote
SpiritWolf
Wanderer


Joined: 02 Jul 2002
Posts: 74
Location: USA

PostPosted: Wed Mar 17, 2004 2:50 pm   
 
Done some looking and found a trigger in another thread that does pretty much what I want to do. After some editing I have it working except for one thing.. I don't know how to get it to turn off on a blank line. This is the trigger I have after some modifications:
#TRIGGER "IDSpellCap" {^Level &dbItem.SpellLevel spells of:$} {}
#COND {} {#IF (%pos( ":", %line)) {dbItem.Grantedspells=%replace( @spells, "|", ",");spells="";#STATE IDSpellCap 0} {#ADDITEM spells {%line}}} {looplines|param=5}

I'm pretty sure the part I need to edit is the #IF (%pos( ":", %line)) part, but not sure how to tell it to match the ":" or a "^$" for a blank line.
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Wed Mar 17, 2004 3:13 pm   
 
#TRIGGER "IDSpellCap" {^Level &dbItem.SpellLevel spells of:$} {}
#COND {} {#IF (%pos( ":", %line)) {dbItem.Grantedspells=%replace( @spells, "|", ",");spells="";#STATE IDSpellCap 0} {#ADDITEM spells {%line}}} {looplines|param=5}
#COND {^$} {#state IDSpellCap 0} {reparse}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Mar 17, 2004 7:43 pm   
 
A trigger can only have one active state. Use a temporary trigger to reset the trigger on a blank line.

#TRIGGER "IDSpellCap" {^Level &dbItem.SpellLevel spells of:$} {#TEMP {^$} {#STATE IDSpellCap 0}}
#COND {} {#IF (%pos( ":", %line)) {dbItem.Grantedspells=%replace( @spells, "|", ",");spells="";#STATE IDSpellCap 0} {#ADDITEM spells {%line}}} {looplines|param=5}
Reply with quote
SpiritWolf
Wanderer


Joined: 02 Jul 2002
Posts: 74
Location: USA

PostPosted: Wed Mar 17, 2004 8:52 pm   
 
Err..
What I ment by turning it off on a blank line was that the conditional part of the trigger has an "#IF (%pos( ":", %line))" that processes the info the trigger grabs later and resets it back to its original state when it gets the ":" from the "Can affect you as :" line. What I'm trying to figure out is how to make it do the same thing if it catches a blank line when the "Can affect you as :" line isn't there.

I tried editing it to be: #IF (%pos( ":" or "^$", %line))
but that broke the whole thing.
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Wed Mar 17, 2004 9:13 pm   
 
Ah, that's easily done then:

#TRIGGER "IDSpellCap" {^Level &dbItem.SpellLevel spells of:$} {}
#COND {} {#IF (%null(%line)) {} {#IF (%pos( ":", %line)) {dbItem.Grantedspells=%replace( @spells, "|", ",");spells="";#STATE IDSpellCap 0} {#ADDITEM spells {%line}}}} {looplines|param=5}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Mar 18, 2004 3:07 am   
 
quote:
Originally posted by SpiritWolf

Err..
What I ment by turning it off on a blank line was that the conditional part of the trigger has an "#IF (%pos( ":", %line))" that processes the info the trigger grabs later and resets it back to its original state when it gets the ":" from the "Can affect you as :" line. What I'm trying to figure out is how to make it do the same thing if it catches a blank line when the "Can affect you as :" line isn't there.

I tried editing it to be: #IF (%pos( ":" or "^$", %line))
but that broke the whole thing.


Err...
That's exactly what the #TEMP trigger I suggested does.

EDIT: Added quote to clarify which post I was referring to.
Reply with quote
SpiritWolf
Wanderer


Joined: 02 Jul 2002
Posts: 74
Location: USA

PostPosted: Thu Mar 18, 2004 5:33 pm   
 
After some more fiddling and using part of Danlo's suggestion, I've come up with the following trigger which works great.. except that it now captures the "Can affect you as :" line as part of the spell list. On potions without that, it captures just fine. Any suggestions for that lil problem?

#TRIGGER "IDSpellCap" {^Level &dbItem.SpellLevel {spell|spells} of:$} {} "Identify"
#COND {} {#IF (%null( %line)) {dbItem.Grantedspells=%replace( @spells, "|", ",");spells="";#STATE IDSpellCap 0} {#ADDITEM spells {%line}};#IF (%pos( ":", %line)) {dbItem.Grantedspells=%replace( @spells, "|", ",");spells="";#STATE IDSpellCap 0} {#ADDITEM spells {%line}}} {looplines|param=5}
Reply with quote
SpiritWolf
Wanderer


Joined: 02 Jul 2002
Posts: 74
Location: USA

PostPosted: Fri Mar 19, 2004 3:56 pm   
 
Sorry LightBulb. I knew that post you were talking about, but to me it looked like it reset the trigger back to state 0 before the conditional even fired.. and if thats not what it does then it still doesn't work due to it not firing off the blank line to update the info like it does when it fires off the : in the "Can affect you as :" line... Unless of course I'm not understanding how the trigger works exactly. I didn't write it, so been pretty much guessing what things do in it.
The trigger does work fine for potions that have that line, just potions without that line it refuses to capture the spell(s).
Below is an example of a potion without that line.

You complete your spell...
You feel informed:
Object 'shiny potion', Item type: POTION
Item can be worn on:
Item will give you following abilities:
Item is:
Weight: 1, Value: 100
Level 25 spells of:
armor

< 654h/654H 49p/49P 109v/109V >

I can post the entire script if needed, but its quite long.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Mar 19, 2004 8:31 pm   
 
If the #TEMP trigger needs additional commands, just add them. It would be best not to clear variables with the #TEMP, since you might occasionally have more than one and they'll all fire on the same blank line.

#TRIGGER "IDSpellCap" {^Level &dbItem.SpellLevel spells of:$} {spells = "";#TEMP {^$} {dbItem.Grantedspells=%replace( @spells, "|", ",");#STATE IDSpellCap 0}}
#COND {} {#IF (%pos( ":", %line)) {dbItem.Grantedspells=%replace( @spells, "|", ",");spells="";#STATE IDSpellCap 0} {#ADDITEM spells {%line}}} {looplines|param=5}
Reply with quote
SpiritWolf
Wanderer


Joined: 02 Jul 2002
Posts: 74
Location: USA

PostPosted: Sat Mar 20, 2004 4:53 pm   
 
Still not working right. At this point, I'm just thinking about trying to work more with my original trigger since I at least know what its doing, or trying to do.
After reading up on some of the functions this trigger uses, I'm lost as to how %pos and %line are even able to capture what I need.
I just want a trigger that fires on "Level * spells of:" and records anything on any line after that doesn't start with an uppercase letter.
Sounds pretty easy, I just don't know how to go about it.

I thank you guys, expecially LightBulb, for trying to help me and pretty much saying the same things over and over just in diffrent ways.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Mar 20, 2004 6:12 pm   
 
%POS returns the position number(True>=1) of : in the last line recieved if its not there it returns 0 (0=false)

Ok so off the top of my head how about something like this something simple.

#TR "IdSpellCap" {Level * spells of:} {#say DB stuff on level}
#COND {*} {#If (%line=%proper(%line)) {dbItem.Grantedspells=%replace( @spells, "|", ",");spells="";#state IdSpellCap 0} {#additem spells {%line}}} {looplines|param=5}
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Sat Mar 20, 2004 6:19 pm   
 
Hm, I can't see why Lightbulb's solution doesn't work for you, but you might try this:

#trigger "IdSpellCap" {Level &dbItem.SpellLevel spells of:} {spells=%null}
#COND {!%proper(%line)} {#temp {^$} {dbItem.Grantedspells=%replace( @spells, "|", ",");#STATE IDSpellCap 0};#additem spells {%line}} {exp|looplines|param=5}
Reply with quote
SpiritWolf
Wanderer


Joined: 02 Jul 2002
Posts: 74
Location: USA

PostPosted: Sun Mar 21, 2004 3:55 pm   
 
Hmm.. seems LightBulb's trigger is working.. sort of. Its capturing the spell names and sticking them in the dbItem.GrantedSpells variable right.. just for some reason its not getting put in the database. The protections potion I listed in the first post is getting added right, just not the shiny potion with only the armor spell I listed further down.
Might also have something to do with the script also not updating the database correctly if the same item was already found.
Reply with quote
SpiritWolf
Wanderer


Joined: 02 Jul 2002
Posts: 74
Location: USA

PostPosted: Tue Mar 23, 2004 11:14 am   
 
Figured I'd just note that I did come up with a trigger that works like I wanted.

#TRIGGER "IDSpellCap" {^Level &dbItem.SpellLevel {spell|spells} of:$} {} "Identify"
#COND {} {#IF (%null( %line)) {dbItem.Grantedspells=%replace( @spells, "|", ",");spells="";#STATE IDSpellCap 0} {#IF (%pos( ":", %line)) {dbItem.Grantedspells=%replace( @spells, "|", ",");spells="";#STATE IDSpellCap 0} {#ADDITEM spells {%line}}}} {looplines|param=5}


I thank you all for your help! Next step, figuring out why it won't capture some item names or update items in the database if the item is already in there. Thats stuff for another post though. :)
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