119 lines
3.0 KiB
Plaintext
119 lines
3.0 KiB
Plaintext
ASSEMBLY = {
|
|
position = Vector({ x=68, y=2, z=36 }),
|
|
rotation = { x=0, y=270, z=180 }
|
|
}
|
|
|
|
SET_ASIDE_POSITION = {2.27, 1.39, 5.47}
|
|
EXPLORATION_DECK_GUID = "1a1eae"
|
|
RUINS_DECK_GUID = "a25525"
|
|
RUINS = {
|
|
{ name="Overgrown Ruins", position={-36.77, 1.64, -7.70} },
|
|
{ name="Temple of the Fang", position={-36.77, 1.65, 7.57} },
|
|
{ name="Stone Altar", position={-36.77, 1.65, -0.03} }
|
|
}
|
|
|
|
ASSEMBLY_OFFSET = Vector({ 0, 0, -4})
|
|
|
|
function onLoad()
|
|
self.createButton({
|
|
label="Ruins in play", click_function="setup_in_play", function_owner=self,
|
|
position={0,0.3,2}, rotation={0,0,0}, height=300, width=1800,
|
|
font_size=250, color={0,0,0}, font_color={1,1,1}
|
|
})
|
|
self.createButton({
|
|
label="Shuffle ruins in", click_function="setup_shuffle_in", function_owner=self,
|
|
position={0,0.3,2.8}, rotation={0,0,0}, height=300, width=1800,
|
|
font_size=250, color={0,0,0}, font_color={1,1,1}
|
|
})
|
|
makeIndexes()
|
|
math.randomseed(os.time())
|
|
end
|
|
|
|
function makeIndexes()
|
|
ruinsMap = {}
|
|
for i,v in ipairs(RUINS) do
|
|
ruinsMap[v.name] = v
|
|
end
|
|
end
|
|
|
|
function setup_in_play(obj, color, alt_click)
|
|
ruins_in_play = true
|
|
setup(obj, color, alt_click)
|
|
end
|
|
|
|
function setup_shuffle_in(obj, color, alt_click)
|
|
ruins_in_play = false
|
|
setup(obj, color, alt_click)
|
|
end
|
|
|
|
function setup(obj, color, alt_click)
|
|
if DISABLED then return end
|
|
DISABLED = true
|
|
local objs = self.getObjects()
|
|
for i=#objs,1,-1 do
|
|
self.takeObject({
|
|
position = ASSEMBLY.position + (ASSEMBLY_OFFSET * i),
|
|
rotation = ASSEMBLY.rotation,
|
|
smooth = false,
|
|
callback_function=function(obj) pickRandomCard(obj) end
|
|
})
|
|
end
|
|
|
|
self.setPosition(SET_ASIDE_POSITION)
|
|
Wait.time(setup_2, 1)
|
|
end
|
|
|
|
function setup_2()
|
|
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
|
|
})
|
|
|
|
local deck
|
|
for i,v in ipairs(objs) do
|
|
if v.hit_object.tag == "Deck" then
|
|
deck = v.hit_object
|
|
break
|
|
end
|
|
end
|
|
|
|
deck.shuffle()
|
|
explorationDeck = getObjectFromGUID(EXPLORATION_DECK_GUID)
|
|
deck.setPosition(explorationDeck.getPosition() + Vector({0, 2, 0}))
|
|
|
|
local ruins = getObjectFromGUID(RUINS_DECK_GUID)
|
|
ruins.shuffle()
|
|
local ruin = ruins.getObjects()[1]
|
|
if ruins_in_play then
|
|
ruins.takeObject({
|
|
position = ruinsMap[ruin.name].position,
|
|
rotation = {0, 270, 0},
|
|
smooth = false
|
|
})
|
|
else
|
|
ruins.takeObject({
|
|
position = explorationDeck.getPosition() + Vector({0, 2, 0}),
|
|
smooth = false
|
|
})
|
|
end
|
|
|
|
Wait.time(setup_3, 1)
|
|
end
|
|
|
|
function setup_3()
|
|
explorationDeck.shuffle()
|
|
end
|
|
|
|
function pickRandomCard(obj)
|
|
obj.shuffle()
|
|
obj.takeObject({
|
|
position = ASSEMBLY.position,
|
|
rotation = ASSEMBLY.rotation,
|
|
smooth = false
|
|
})
|
|
self.putObject(obj.remainder)
|
|
end
|