## Anyone know how to do this better? In my game, you can pick up trinkets. Someone asked if they could be stored and I came up with this brute force method of randomly assigning trinkets a value. Maybe you always get the trink1, then trink2, then trink3 and the number randomly assigned to it provides a description? Not sure. Interested in if someone can do this better...

``````[[Start]]:

//RANDOM NUMBER GENERATOR
squiffy.getRndInteger = function(min,max){
return Math.floor(Math.random() * (max - min + 1) ) + min;
};

@set trink1=0
@set trink2=0
@set trink3=0

@set count=1

set("genNum", squiffy.getRndInteger(1,3));

if ((get("genNum")==1) && (get("trink1")==0)){
set("trink1",get("count"));
set("count",get("count")+1);
}

if ((get("genNum")==2) && (get("trink2")==0)){
set("trink2",get("count"));
set("count",get("count")+1);
}

if ((get("genNum")==3) && (get("trink3")==0)){
set("trink3",get("count"));
set("count",get("count")+1);
}

if (get("count")==4){squiffy.story.go("End Loop");}

[[End Loop]]:

trink1 = {trink1}<br>
trink2 = {trink2}<br>
trink3 = {trink3}<br>

[[Try again?]](Start)
`````` The end result is that each trinket should have a unique value. But boy, is this ever a sledgehammer approach.

This topic is now closed. Topics are closed after 60 days of inactivity.

Quest
Squiffy
ActiveLit

Documentation
Blog
GitHub

Forums