172 lines
4.7 KiB
Plaintext
172 lines
4.7 KiB
Plaintext
|
PLAYAREA = {
|
||
|
position = {-20.04, 4.13, 0.37},
|
||
|
rotation = { x=0, y=90, z=0 },
|
||
|
scale = {34.11, 5.10, 49.91}
|
||
|
}
|
||
|
|
||
|
ASSEMBLY = {
|
||
|
position = { x=68, y=2, z=36 },
|
||
|
rotation = { x=0, y=270, z=180 }
|
||
|
}
|
||
|
|
||
|
LOCATIONS = {
|
||
|
{ name = "House in the Reeds", position = Vector({-23.68, 1.65, 7.57}), offset = Vector({3.25, 0, 0}) },
|
||
|
{ name = "Schoolhouse", position = Vector({-23.68, 1.65, -0.03}), offset = Vector({3.25, 0, 0}) },
|
||
|
{ name = "Congregational Church", position = Vector({-30.22, 1.66, 7.57}), offset = Vector({0, 0, 2.5}) },
|
||
|
{ name = "Osborn's General Store", position = Vector({-30.22, 1.65, -7.70}), offset = Vector({0, 0, -2.5}) },
|
||
|
{ name = "Burned Ruins", position = Vector({-36.77, 1.67, 7.57}), offset = Vector({-3.25, 0, 0}) },
|
||
|
{ name = "Bishop's Brook", position = Vector({-36.77, 1.66, -0.03}), offset = Vector({-3.25, 0, 0}) }
|
||
|
}
|
||
|
|
||
|
function onLoad()
|
||
|
self.createButton({
|
||
|
label="Place\nLocations", click_function="setup", function_owner=self,
|
||
|
position={2,0.3,0}, rotation={0,270,0}, height=600, width=1200,
|
||
|
font_size=250, color={0,0,0}, font_color={1,1,1}
|
||
|
})
|
||
|
makeIndexes()
|
||
|
math.randomseed(os.time())
|
||
|
end
|
||
|
|
||
|
function makeIndexes()
|
||
|
local removedLoc = math.random(6)
|
||
|
locationMap = {}
|
||
|
for i,loc in ipairs(LOCATIONS) do
|
||
|
if i ~= removedLoc then
|
||
|
locationMap[loc.name] = loc
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function getPlayAreaObjects()
|
||
|
return Physics.cast({
|
||
|
origin = PLAYAREA.position,
|
||
|
direction = { x=0, y=1, z=0 },
|
||
|
type = 3,
|
||
|
size = PLAYAREA.scale,
|
||
|
orientation = PLAYAREA.rotation
|
||
|
})
|
||
|
end
|
||
|
|
||
|
function getAssemblyDeck()
|
||
|
local objs = Physics.cast({
|
||
|
origin = ASSEMBLY.position,
|
||
|
direction = { x=0, y=1, z=0 },
|
||
|
type = 3,
|
||
|
size = { x=3, y=3, z=3 },
|
||
|
orientation = ASSEMBLY.rotation
|
||
|
})
|
||
|
|
||
|
for i,v in ipairs(objs) do
|
||
|
if v.hit_object.tag == "Deck" then
|
||
|
return v.hit_object
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return nil
|
||
|
end
|
||
|
|
||
|
function setup(obj, color, alt_click)
|
||
|
playerColor = color
|
||
|
local objs = self.getObjects()
|
||
|
for i=#objs,1,-1 do
|
||
|
local name = objs[i].name
|
||
|
local loc = locationMap[name]
|
||
|
if name ~= nil and loc ~= nil then
|
||
|
self.takeObject({
|
||
|
position = loc.position,
|
||
|
rotation = { 0, 270, 0 },
|
||
|
smooth = false,
|
||
|
index = i - 1
|
||
|
})
|
||
|
end
|
||
|
end
|
||
|
|
||
|
Wait.time(setup_2, 1)
|
||
|
end
|
||
|
|
||
|
function setup_2()
|
||
|
local objs = getPlayAreaObjects()
|
||
|
for i,v in ipairs(objs) do
|
||
|
local obj = v.hit_object
|
||
|
local name = obj.getName()
|
||
|
if name == "Set-aside" then
|
||
|
chest = obj
|
||
|
elseif name == "Encounter Deck" then
|
||
|
encounterDeck = obj
|
||
|
else
|
||
|
local loc = locationMap[name]
|
||
|
if loc ~= nil then
|
||
|
obj.shuffle()
|
||
|
obj.takeObject({
|
||
|
position = self.getPosition() + Vector({ 0, 5, 0}),
|
||
|
smooth = false
|
||
|
})
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
self.editButton({
|
||
|
index = 0,
|
||
|
click_function = "setup_3",
|
||
|
function_owner = self,
|
||
|
label = "Place Key &\nChamber"
|
||
|
})
|
||
|
|
||
|
broadcastToColor("Read setup and shuffle Naomi's Crew encounter set into the " ..
|
||
|
'encounter deck if necessary, then click "Place Key & Chamber"',
|
||
|
playerColor, { r=1, g=1, b=0 })
|
||
|
end
|
||
|
|
||
|
function setup_3()
|
||
|
if DISABLED then return end
|
||
|
DISABLED = true
|
||
|
takeObjectiveCards(chest)
|
||
|
takeEncounterCards(encounterDeck)
|
||
|
Wait.time(setup_4, 1)
|
||
|
end
|
||
|
|
||
|
function setup_4()
|
||
|
local deck = getAssemblyDeck()
|
||
|
deck.shuffle()
|
||
|
local i = 1
|
||
|
for name,loc in pairs(locationMap) do
|
||
|
if i < (#LOCATIONS - 1) then
|
||
|
deck.takeObject({
|
||
|
position = loc.position + loc.offset,
|
||
|
rotation = ASSEMBLY.rotation,
|
||
|
smooth = false
|
||
|
})
|
||
|
else
|
||
|
deck.remainder.setPosition(loc.position + loc.offset)
|
||
|
end
|
||
|
i = i + 1
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function takeObjectiveCards(chest)
|
||
|
local objs = chest.getObjects()
|
||
|
for i=#objs,1,-1 do
|
||
|
local name = objs[i].name
|
||
|
if name == "The Hidden Chamber" or name == "Key to the Chamber" then
|
||
|
chest.takeObject({
|
||
|
position = ASSEMBLY.position,
|
||
|
rotation = ASSEMBLY.rotation,
|
||
|
smooth = false,
|
||
|
index = i - 1
|
||
|
})
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function takeEncounterCards(deck)
|
||
|
deck.shuffle()
|
||
|
for i=1,3 do
|
||
|
deck.takeObject({
|
||
|
position = ASSEMBLY.position,
|
||
|
rotation = ASSEMBLY.rotation,
|
||
|
smooth = false,
|
||
|
index = i - 1
|
||
|
})
|
||
|
end
|
||
|
end
|