Howdy, Stranger!

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

Changing variables in a string affects the printed output dynamically. Any alternative?

Hello, everyone. I'm trying to create a random item generator and ran into some problems. I couldn't really explain my problem clearly in the title, so I'll just give an example:

Example 1:
<<set $item to "Sword">>
<<set $item_fullname to $item>>
<<set $item to "Axe">>
<<print $itemA_fullname>> // This print action still generates "Sword" even though I have changed the variable $item to "Axe" due to the fact that I didn't put the quotation marks "". This is the behavior I'm trying to achieve. //



<<set $prefix to "Rusty">>
<<set $item to "Sword">>
<<set $suffix to "of the Monkey">>
<<set $itemA_fullname to "$prefix" + " $item " + "$suffix">>
<<set $item to "Axe">>
<<print $itemA_fullname>> // Unfortunately, this print action generates the output "Rusty Axe of the Monkey", when the behavior I'm trying to achieve is "Rusty Sword of the Monkey". It appears that due to the quotation marks, the properties of the variable $itemA_fullname dynamically updates to the changes within the string. //

So I tried removing the quotation marks like so:
<<set $itemA_fullname to $prefix + $item + $suffix>>

And unfortunately, the printed output is like so: "RustySwordof the Monkey"
The lack of spacing in between the words makes it look terrible....

I guess my question is.... is there an alternative way of going about this so that the variable $itemA_fullname doesn't dynamically change when I change the $prefix, $item and/or $suffix variables? I apologize if I didn't word this whole post properly... :/

Comments

Sign In or Register to comment.