Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Assigning values to an object from a list of random objects in sugarcube

$
0
0
Hi,

For my game I need to be able to assign commanders with pre determined stats to a specific location at random.
What I mean by this is: I have a commander spot (Commander1) which has to be filled from the StoryInit. This is an object with several keys, which are similar between all commanders but with different values.

Instead of assigning the same commander with the same stats to this at every game, I instead have a list of different commanders, each with their own stats.

What I now want is that I'm able to randomly pick a commander from that list (of about 150 commander types), then assign that commander with it's stats to the spot Commander1.

The only way I can think of would require about 150 if statements per spot, so with over 190 spots that would become a very long and slow process.
Is there a more efficient way to do this?

Another way (which I tried but didn't work) would use a sort of variable in a variable. Like this:
<<set $random to random(10)>>
<<set $object1 ={Attack: $commander[$random].Attack, Defence: $commander[$random].Defence}>>

Thanks in advance

Viewing all articles
Browse latest Browse all 1844

Trending Articles