BYSTANDERS_GUID = "a2d9f5" BYSTANDERS_RETURN_TO_GUID = "dc02e3" PLAYAREA_GUID = "721ba2" LOCATIONS_GUID = { { guid="aa08d4", offset=Vector({ 0, 0, 2.42 }) }, { guid="c605d3", offset=Vector({ 0, 0, 2.42 }) }, { guid="981fa3", offset=Vector({ 3.14, 0, 0 }) }, { guid="b3c25b", offset=Vector({ 0, 0, -2.31 }) }, { guid="cce10d", offset=Vector({ 0, 0, -2.31 }) } } function onLoad() self.createButton({ label="Set Up", click_function="setup", function_owner=self, position={0,0.1,0.4}, height=120, width=400, scale={x=1.75, y=1.75, z=1.75}, font_size=100 }) playarea = getObjectFromGUID(PLAYAREA_GUID) PLAYER_COUNTER = getObjectFromGUID('f182ee') math.randomseed(os.time()) end function setup(obj, color, alt_click) local bystanders = getObjectFromGUID(BYSTANDERS_GUID) if bystanders == nil then bystanders = getObjectFromGUID(BYSTANDERS_RETURN_TO_GUID) if bystanders == nil then printToColor("Bystanders deck not found", color) return end end -- place bystanders bystanders.shuffle() local cards = bystanders.getObjects() local bPositions = {} for i=1,#LOCATIONS_GUID-1 do local b = cards[i] local loc = LOCATIONS_GUID[i] local pos = getObjectFromGUID(loc.guid).getPosition() + loc.offset bystanders.takeObject({ guid = b.guid, position = pos, smooth = false }) table.insert(bPositions, pos) end local finalLoc = LOCATIONS_GUID[5] local finalPos = getObjectFromGUID(finalLoc.guid).getPosition() + finalLoc.offset bystanders.remainder.setPosition(finalPos) table.insert(bPositions, finalPos) -- spawn clues local numClues = PLAYER_COUNTER.getVar('val') + 1 for i=1,#LOCATIONS_GUID do local bPos = bPositions[i] for j=0,numClues-1 do local pos = bPos if j < 4 then pos = pos + Vector(0.3, 0.2, (0.55*j) - 0.8) else pos = pos + Vector(0.85, 0.2, (0.55*j) - 3) end Global.call("spawnToken", { pos, "clue" }) end end end