 |
AtriumXP Beginner
Joined: 02 Feb 2012 Posts: 16
|
Posted: Thu Feb 02, 2012 6:52 pm
Beginner scripting help request - inventory management for potions |
Hi, everyone!
I've got a few basic scripts working but just jumping into trigger-based variable loading and the like.
What's the proper way to set this up:
Button on my toolbar to display "Blues: " (and displays value of @blues, the #of blue potions left in my inventory)
First trigger: "You quaff a blue potion." (decrements @blues by one)
Second trigger: "You buy x A blue potions." (increments @blues by x, and yes the spelling is exact for that trigger line lol).
I got my bank account to work with this trigger: "Your current balance is &%d{bankacct} gold coins." (just stores the value right in) and a button where the caption is simply "Bank: @bankacct".
I've been playing at this a few times but I think my syntax is off. I'm pretty sure it's much faster to learn the right way from you pros, so here I am.
My attempt (obviously not working):
Button: "Blues: @blues" (I'm certain this is correct)
Trigger 1: "You quaff a blue potion." (executes: #VAR blues @blues - 1)
Trigger 2: "You buy %d a blue potions." (executes: #VAR blues @blues + %1)
Thanks in advance for putting up with a noob :D |
|
|
 |
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Thu Feb 02, 2012 7:02 pm |
You'll need to put parentheses around your expressions to tell CMUD to evaluate it. Also, in your second trigger, %1 will be undefined - in order to capture a part of the pattern to %1, %2, etc. you need to put parentheses around it. The correct code would be:
Code: |
#TRIGGER {You quaff a blue potion.} {#VAR blues (@blues - 1)}
#TRIGGER {You buy (%d) a blue potions.} {#VAR blues (@blues + %1)} |
|
|
|
 |
AtriumXP Beginner
Joined: 02 Feb 2012 Posts: 16
|
Posted: Thu Feb 02, 2012 7:34 pm |
It's painful that I was that close :p
Thanks for the tips, it's working perfectly now. |
|
|
 |
|
|