Hey! I’m working on some code in Verse and I’m stuck on how to get it right.
I want to create an array of trigger devices. When the game starts, a random trigger should be activated, but in the next round, it shouldn’t be the same as the last one. Is there a way to do this?
This is what I have right now and it doesn’t work:
@editable MountainIndex:[]trigger_device = array{}
var LastMountainSelection:weak_map(session, int) = map{}
OnBegin<override>()<suspends>:void=
RandomizeMountain()
RandomizeMountain():void=
mountainIDX:= GetRandomInt(0, MountainIndex.Length - 1)
X := if (Y := LastMountainSelection[GetSession()]) then Y + mountainIDX else 0
if (mountainIDX = X):
Print ("Rerolling mountain...")
RandomizeMountain()
else:
for (Index := mountainIDX..MountainIndex.Length - 1):
if (Element := MountainIndex[Index]):
Element.Trigger()
if:
set LastMountainSelection[GetSession()] = X
Print("This Mountain selection was {X}")