Hello everyone!
Currently I'm working on creating a small game and I am rather fond of random things but I am currently running into a problem.
I try to create random things, let's say like this:
Weapon - can be a spear, a sword, an axe
made out of - wood, iron, bronze
with a random crystal attached - namely sapphire, ruby, etc.
so it would look like this:
<<set $Weapon to ["Sword", "Spear", "Bow", "Axe", "Staff"]>>
<<set $Material to ["Stone", "Bronze", "Silver", "Iron", "Wood"]
<<set $Gem to ["Ruby", "Emerald", "Saphire"]>>
These would allow for randomly created items with one characteristic from each of these three categories. Now I only need to know on how to incorporate all of these into a single item.
I think I have to work with arrays to get this done, which actually isn't such a problem to set up - I just need to understand how these randomly generated items can be added into the game. It might be necessary to use the .push - thingy, but I am still puzzled on how to do it right.
Oh, I am using sugarcube by the way but don't let that stop you.
Comments
Anyway. You could do something like the following in your StoryInit special passage:
Then to create a new random item, weapon in this case, you could do something like the following:
Now, let's say you wanted to print out the details of the new weapon (object): You could also wrap that up in a widget macro for ease of use.
Or, say you wanted to so something based on one or more of the attributes:
It is a global scoped variable that you can add your own custom properties/methods to so that they are available everywhere in your story, these custom values are not tracked or stored with either History or Saves.
The difference is largely moot for the vast majority of users, however, some occasionally do strange things—e.g. using the on… event properties—so it does pay to keep the difference in mind.