-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmapspawner.ttslua
95 lines (83 loc) · 3.89 KB
/
mapspawner.ttslua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
-- Licensed under Creative Commons By 4.0 (https://creativecommons.org/licenses/by/4.0/legalcode)
#include maps
function onLoad(save_state)
self.createButton({click_function = "spawnAutumn", function_owner = self, label = "Autumn Map", position = {0, 1, 4}, rotation = {0, 180, 0}, scale = {2, 2, 2}, width = 2100, height = 400, font_size = 300, color = {0.956, 0.392, 0.113, 1}})
self.createButton({click_function = "spawnWinter", function_owner = self, label = "Winter Map", position = {0, 1, 2}, rotation = {0, 180, 0}, scale = {2, 2, 2}, width = 2100, height = 400, font_size = 300, color = {0.5528, 0.759, 0.9947, 1}})
self.createButton({click_function = "spawnLake", function_owner = self, label = "Lake Map (default)", position = {0, 1, 0}, rotation = {0, 180, 0}, scale = {2, 2, 2}, width = 2100, height = 400, font_size = 200, color = {0.2739, 0.8414, 0.2477, 1}})
self.createButton({click_function = "spawnLakeRandom", function_owner = self, label = "Lake Map (random)", position = {0, 1, -2}, rotation = {0, 180, 0}, scale = {2, 2, 2}, width = 2100, height = 400, font_size = 200, color = {0.2739, 0.8414, 0.2477, 1}})
self.createButton({click_function = "spawnMountain", function_owner = self, label = "Mountain Map", position = {0, 1, -4}, rotation = {0, 180, 0}, scale = {2, 2, 2}, width = 2100, height = 400, font_size = 200, color = {0.627, 0.125, 0.941, 1}})
self.createButton({click_function = "spawnMountainRandom", function_owner = self, label = "Mountain Map (random)", position = {0, 1, -6}, rotation = {0, 180, 0}, scale = {2, 2, 2}, width = 2100, height = 400, font_size = 200, color = {0.627, 0.125, 0.941, 1}})
self.setName("Setup Map")
end
function spawnAutumn()
spawnMap("Autumn", false)
end
function spawnWinter()
spawnMap("Winter", true)
end
function spawnLake()
spawnMap("Lake", false)
end
function spawnLakeRandom()
spawnMap("Lake", true)
end
function spawnMountain()
spawnMap("Mountain", false)
end
function spawnMountainRandom()
spawnMap("Mountain", true)
end
function spawnMap(map, random)
ruinItemBags = {getObjectFromGUID("005fc0"), getObjectFromGUID("d65302"), getObjectFromGUID("fd5932")}
self.destruct()
-- map and items
for _, x in ipairs(map_data[map].map) do
spawnObjectJSON({json=x})
end
-- ruins and ruin items
available = Global.getTable('available')
print(logString(available))
-- Spawn items if we have Boars and no vagabonds
vagabonds = math.max(2-available.Vagabond, 1-available.Boars, 1-available.Raggoon)
local params = {}
params.rotation = {0, 180, 0}
params.smooth = false
if vagabonds > 0 then
for x=1, vagabonds do
ruinItemBags[x].shuffle()
for _, y in ipairs(map_data[map].ruins) do
params.position = y
params.position[2] = params.position[2]+(x-1)*0.1
ruinItemBags[x].takeObject(params)
end
end
else
params.callback_function = function(o) o.lock() end
end
for _, x in ipairs(map_data[map].ruins) do
params.position = x
params.position[2] = params.position[2]+vagabonds*0.1
ruinItemBags[3].takeObject(params)
end
for _, x in ipairs(ruinItemBags) do
x.destruct()
end
-- clearing markers
local clearingMarkerBag = getObjectFromGUID("e060fd")
if map_data[map]["clearing_markers"] ~= nil then
if random == true then clearingMarkerBag.shuffle() end
local params = {}
params.callback_function = function(o) o.lock() end
params.smooth = false
for _, x in ipairs(map_data[map].clearing_markers) do
params.position = x.position
params.rotation = x.rotation
clearingMarkerBag.takeObject(params)
end
end
clearingMarkerBag.destruct()
-- note
if map_data[map]['note'] ~= nil then
setNotes(map_data[map]['note'])
end
end