Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to store strings and vars inside another var

Sorry if I wasn't clear, maybe I don't know how to explain, only showing.
Let's suppose I have this:
You've found a shield!(click:"shield")[(set: $inventory to it + (a: $shield))]

So when the player clicks "shield", the item (set in another place) will be stored in my "items" array.
But write all this code all time where there is an item can bloat the code a bit. How can I, if possible, do something like:
You've found a $itemshield

where $itemshield is (link-reveal:"shield")[(set: $inventory to it + (a: $shield))]?

Comments

  • Try something like the following:
    (set: $itemshield to "(link-reveal: 'shield')[(set: $inventory to it + (a: $shield))]")
    
    You've found a $itemshield
    
    ... notice that the (link-reveal:) macro's String parameter is wrapped in single quotes instead of double quotes, this is so we can have a String value within a String.
  • Great, thanks!
Sign In or Register to comment.