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


Joined: 02 Feb 2012
Posts: 16

PostPosted: 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
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: 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)}
Reply with quote
AtriumXP
Beginner


Joined: 02 Feb 2012
Posts: 16

PostPosted: 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.
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