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
zelenik
Beginner


Joined: 23 Sep 2006
Posts: 11

PostPosted: Fri May 01, 2020 3:11 am   

Script that writes a trigger using a variable to define the trigger name
 
Hi. I am trying to write a script that writes triggers for me based on certain actions I take in game. The challenge is that the script must name the triggers from values in a variable and assign the action from variable value. For example:

#TR {@Item} {#echo @Spell}

The goal is to create a trigger for special Items that I see in game that echoes certain traits like the spells a scroll casts. I'm sure I'm missing something easy to expand the variable. There may be another way to do this with a database variable, but I couldn't for the life of me figure that one out either.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Fri May 01, 2020 12:33 pm   
 
Assuming that @item is a list of items, you need an extra set of braces to expand it:

#TR {{@Item}} {#echo @Spell}
_________________
Discord: Shalimarwildcat
Reply with quote
zelenik
Beginner


Joined: 23 Sep 2006
Posts: 11

PostPosted: Fri May 01, 2020 2:13 pm   
 
Currently, I am trying to make a trigger from each new items added to a database. Before I pass the item to the database, I store details in variables. @Item holds the name of a single item and @Spell holds details about any spells it can cast. Example:

Item = Purple staff
Spell = Cure light wounds

I want to create a #yesno that will create a trigger looking for Purple staff and echo (cure light wounds)
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Sat May 02, 2020 3:22 am   
 
You will likely need to cobble your question string together with %concat if you want to reference the variables in the question.

Show me your #YESNO command if it is failing; I can't troubleshoot code that isn't there.
_________________
Discord: Shalimarwildcat
Reply with quote
zelenik
Beginner


Joined: 23 Sep 2006
Posts: 11

PostPosted: Sun May 03, 2020 3:58 am   
 
Forgive me as this will likely be the least elegant script you have ever seen. My database is effective for storing details about items that I identify. The challenge is in the if statement with the space above and below. That is where I am trying to automate the generation of a trigger. The goal is to create triggers that creates visual tags to remind me about the abilities on certain items, so I can find them easier in containers and storage. If I can get those variables to unpack into the trigger, I can deploy the trigger creation script in many ways. I'll take any other feedback as well about this script. I love the logic piece of writing scripts, but have no formal training.

Code:
identified=%concat(%trim(@identified), " ",  %trim(%line))
   #IF (%trim(%line)=%null) {
   #wait 1000
   #GAGON
      #ECHO %match(@identified,"This is (*), a {tiny|small|medium|large|giant|huge} (%w) (*), weighing approximately (%d) lbs.",ItemName,ItemMaterial,ItemType,ItemWeight)
      #ECHO (%match(@identified,"The pill has (*).  It is",Spells))
      #ECHO (%match(@identified,"The pill has (*). It is",Spells))
      #ECHO (%match(@identified,"The scroll has (*).  It is",Spells))
      #ECHO (%match(@identified,"The scroll has (*). It is",Spells))
      #ECHO (%match(@identified,"The wand holds (*). It is",Spells))
      #ECHO (%match(@identified,"The wand holds (*).  It is",Spells))
      #ECHO (%match(@identified,"The potion has (*). It is",Spells))
      #ECHO (%match(@identified,"The potion has (*).  It is",Spells))
      #ECHO (%match(@identified,"The staff holds (*).  It is",Spells))
      #ECHO (%match(@identified,"The staff holds (*). It is",Spells))
      #ECHO (%match(@identified,"It bears an innate endowment to (%w) (%w) fortitude.",$level1,$direction1)) 
      #IF ($level1 != "") {Attribute1 = %concat($level1," ",$direction1," fortitude, ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) magical protection.",$level2,$direction2)
      #IF ($level2 != "") {Attribute2 = %concat($level2," ",$direction2," magical protection, ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) armor protection.",$level3,$direction3)
      #IF ($level3 != "") {Attribute3 = %concat($level3," ",$direction3," armor protection. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) charisma.",$level4,$direction4)
      #IF ($level4 != "") {Attribute4 = %concat($level4," ",$direction4," charisma. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) combat endurance.",$level5,$direction5)
      #IF ($level5 != "") {Attribute5 = %concat($level5," ",$direction5," combat endurance. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) constitution.",$level6,$direction6)
      #IF ($level6 != "") {Attribute6 = %concat($level6," ",$direction6," constitution. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) dexterity.",$level7,$direction7)
      #IF ($level7 != "") {Attribute7 = %concat($level7," ",$direction7," dexterity. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) intelligence.",$level8,$direction8)
      #IF ($level8 != "") {Attribute8 = %concat($level8," ",$direction8," intelligence. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) magical energy.",$level9,$direction9)
      #IF ($level9 != "") {Attribute9 = %concat($level9," ",$direction9," magical energy. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) reflex.",$level10,$direction10)
      #IF ($level10 != "") {Attribute10 = %concat($level10," ",$direction10," reflex. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) strength.",$level11,$direction11)
      #IF ($level11 != "") {Attribute11 = %concat($level11," ",$direction11," strength. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) travel endurance.",$level12,$direction12) 
      #IF ($level12 != "") {Attribute12 = %concat($level12," ",$direction12," travel endurance. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) weapon accuracy.",$level13,$direction13)
      #IF ($level13 != "") {Attribute13 = %concat($level13," ",$direction13," weapon accuracy. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) weapon damage.",$level14,$direction14)
      #IF ($level14 != "") {Attribute14 = %concat($level14," ",$direction14," weapon damage. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) weapon speed.",$level15,$direction15)
      #IF ($level15 != "") {Attribute15 = %concat($level15," ",$direction15," weapon speed. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) willpower.",$level16,$direction16)
      #IF ($level16 != "") {Attribute16 = %concat($level16," ",$direction16," willpower. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) wisdom.",$level17,$direction17)
      #IF ($level17 != "") {Attribute17 = %concat($level17," ",$direction17," wisdom. ")}
      #ECHO %match(@identified,"It bears an innate endowment to (%w) (%w) magical resistance.",$level18,$direction18) 
      #IF ($level18 != "") {Attribute18 = %concat($level18," ",$direction18," magical resistance.")}
      Attributes= %concat(@Attribute1,@Attribute2,@Attribute3,@Attribute4,@Attribute5,@Attribute6,@Attribute7,@Attribute8,@Attribute9,@Attribute10,@Attribute11,@Attribute12,@Attribute13,@Attribute14,@Attribute15,@Attribute16,@Attribute17,@Attribute18)
      #DBLoad Items
      #IF (%match(@identified,"You failed.") or %match @ItemName=%null) {} {
      #IF (%find(@ItemName,Items,Name) != %null) {} {
      #NEW Items Name=@ItemName Material=@ItemMaterial Type=@ItemType Attribute=@Attributes Spells=@Spells Identified=@identified

 
#IF (@Spells != "") {#YESNO "Do you want to create reminder text for this item?" {#TRIGGER {%concat(@ItemName)} {#ECHO %concat(@Spells)} "SpellItems"}
       {}} {}     


#DBSAVE Items
      #SHOW %find(@ItemName,Items,Name)
      }}
      #ECHO %match(@identified,"It bears an (*).",&enhancement1)
      #IF (@enhancement1 != "") {#YESNO "Would you like to say the endowments?" {#SEND Say It bears an @enhancement1.} {} }
      #IF (@Spells != "") {#YESNO "Would you like to say the Spells?" {#SEND Say It has @Spells.} {}}
      #GAGOFF
      #SHOW Bingo!
     
   } {#STATE 1}
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Sun May 03, 2020 11:20 am   
 
you want this:

#YESNO "Do you want to create reminder text for this item?" {#EXEC %concat("#TRIGGER {", @ItemName, "} {#ECHO ", @Spells, "} {SpellItems}")}
_________________
Discord: Shalimarwildcat
Reply with quote
zelenik
Beginner


Joined: 23 Sep 2006
Posts: 11

PostPosted: Mon May 04, 2020 2:31 am   
 
Thank you, sir. This works great.
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