-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodmain.lua
187 lines (163 loc) · 6.57 KB
/
modmain.lua
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
PrefabFiles = {
"compostpile",
}
Assets = {
Asset("IMAGE", "images/inventoryimages/compostpile.tex"),
Asset("ATLAS", "images/inventoryimages/compostpile.xml"),
}
STRINGS = GLOBAL.STRINGS
function TableMerge(t1, t2)
for k,v in pairs(t2) do
if type(v) == "table" then
if type(t1[k] or false) == "table" then
TableMerge(t1[k] or {}, t2[k] or {})
else
t1[k] = v
end
else
t1[k] = v
end
end
return t1
end
NEWSTRINGS = GLOBAL.require("compostingtogetherstrings")
GLOBAL.STRINGS = TableMerge(GLOBAL.STRINGS, NEWSTRINGS)
-- Compost Pile Recipe
TUNING.COMPOSTPILE_COST_ROCKS = 6
TUNING.COMPOSTPILE_COST_POOP = 4
TUNING.COMPOSTPILE_COST_LOG = 3
if (GetModConfigData("poop_amount") == "low") then
TUNING.COMPOSTPILE_COST_ROCKS = 2
TUNING.COMPOSTPILE_COST_POOP = 1
TUNING.COMPOSTPILE_COST_LOG = 2
end
if (GetModConfigData("poop_amount") == "high") then
TUNING.COMPOSTPILE_COST_ROCKS = 10
TUNING.COMPOSTPILE_COST_POOP = 5
TUNING.COMPOSTPILE_COST_LOG = 8
end
local recipe = AddRecipe("compostpile", {
GLOBAL.Ingredient("rocks", TUNING.COMPOSTPILE_COST_ROCKS),
GLOBAL.Ingredient("log", TUNING.COMPOSTPILE_COST_LOG),
GLOBAL.Ingredient("poop", TUNING.COMPOSTPILE_COST_POOP)
},
GLOBAL.RECIPETABS.FARM,
GLOBAL.TECH.SCIENCE_ONE,
"compostpile_placer"
)
recipe.atlas = "images/inventoryimages/compostpile.xml"
-- Add harvesting action to compost pile
local fn = GLOBAL.ACTIONS.HARVEST.fn
GLOBAL.ACTIONS.HARVEST.fn = function(act)
if act.target.components.composter then
act.target.components.composter:Harvest(act.doer)
return true
else
return fn(act)
end
end
AddAction("COMPOST", "Compost", function(act)
if act.target.components.composter ~= nil then
if act.target.components.composter:IsComposting() then
return true
end
local container = act.target.components.container
if container ~= nil and container:IsOpen() and not container:IsOpenedBy(act.doer) then
return false, "INUSE"
elseif not act.target.components.composter:CanCompost() then
return false
end
act.target.components.composter:StartComposting()
return true
end
end)
AddComponentAction("SCENE", "composter", function(inst, doer, actions, right)
if not inst:HasTag("burnt") and
not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding()) then
if inst:HasTag("donecomposting") then
table.insert(actions, GLOBAL.ACTIONS.HARVEST)
end
end
end)
-- AddComponentAction("SCENE", "composter", function(inst, doer, actions, right)
-- if not inst:HasTag("burnt") and
-- not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding()) then
-- if inst:HasTag("donecomposting") then
-- table.insert(actions, GLOBAL.ACTIONS.HARVEST)
-- elseif right and inst:HasTag("readytocompost") then
-- table.insert(actions, GLOBAL.ACTIONS.COMPOST)
-- end
-- end
-- end)
-- constants
-- composting times
TUNING.COMPOSTPILE_SMALLCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 3
TUNING.COMPOSTPILE_MEDCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 2
TUNING.COMPOSTPILE_LARGECOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 2.2
TUNING.COMPOSTPILE_ENLIGHTEDCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 4
-- TUNING.COMPOSTPILE_SMALLCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 0.025
-- TUNING.COMPOSTPILE_MEDCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 0.025
-- TUNING.COMPOSTPILE_LARGECOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 0.025
-- TUNING.COMPOSTPILE_ENLIGHTEDCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 0.025
if (GetModConfigData("compost_duration") == "realistic") then
TUNING.COMPOSTPILE_SMALLCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 5
TUNING.COMPOSTPILE_MEDCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 3.5
TUNING.COMPOSTPILE_LARGECOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 4
TUNING.COMPOSTPILE_ENLIGHTEDCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 7
end
if (GetModConfigData("compost_duration") == "efficient") then
TUNING.COMPOSTPILE_SMALLCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 2
TUNING.COMPOSTPILE_MEDCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 1.2
TUNING.COMPOSTPILE_LARGECOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 1.4
TUNING.COMPOSTPILE_ENLIGHTEDCOMPOST_TIME = TUNING.TOTAL_DAY_TIME * 2.4
end
-- recipe poop values
TUNING.COMPOSTPILE_SMALLCOMPOST_POOPAMOUNT = 2
TUNING.COMPOSTPILE_MEDCOMPOST_POOPAMOUNT = 4
TUNING.COMPOSTPILE_LARGECOMPOST_POOPAMOUNT = 6
if (GetModConfigData("poop_amount") == "low") then
TUNING.COMPOSTPILE_SMALLCOMPOST_POOPAMOUNT = 1
TUNING.COMPOSTPILE_MEDCOMPOST_POOPAMOUNT = 2
TUNING.COMPOSTPILE_LARGECOMPOST_POOPAMOUNT = 3
end
if (GetModConfigData("poop_amount") == "high") then
TUNING.COMPOSTPILE_SMALLCOMPOST_POOPAMOUNT = 3
TUNING.COMPOSTPILE_MEDCOMPOST_POOPAMOUNT = 5
TUNING.COMPOSTPILE_LARGECOMPOST_POOPAMOUNT = 7
end
-- composting high amounts of rotted stuff triggers the bonus (if the stuff is rotted 33% or lower (avg), you receive a bonus of 1 poop)
TUNING.COMPOSTPILE_ROTTYNESS_THRES = 0.33
TUNING.COMPOSTPILE_ROTTYNESS_POOP_BONUS_LOW = 0
TUNING.COMPOSTPILE_ROTTYNESS_POOP_BONUS_HIGH = 2
if (GetModConfigData("poop_amount") == "low") then
TUNING.COMPOSTPILE_ROTTYNESS_POOP_BONUS_LOW = 0
TUNING.COMPOSTPILE_ROTTYNESS_POOP_BONUS_HIGH = 1
end
if (GetModConfigData("poop_amount") == "high") then
TUNING.COMPOSTPILE_ROTTYNESS_POOP_BONUS_LOW = 0
TUNING.COMPOSTPILE_ROTTYNESS_POOP_BONUS_HIGH = 3
end
-- composting some fruits and veggies with this value, the fertility increases permanently (UPGRADE!)
TUNING.COMPOSTPILE_FERTILESOIL_THRES = TUNING.COMPOSTPILE_LARGECOMPOST_POOPAMOUNT+TUNING.COMPOSTPILE_ROTTYNESS_POOP_BONUS_HIGH
TUNING.COMPOSTPILE_FERTILE_SOIL_ADVANTAGE_PERCENT = 0.2
if (GetModConfigData("fertile_soil_advantage") == "low") then
TUNING.COMPOSTPILE_FERTILE_SOIL_ADVANTAGE_PERCENT = 0.1
end
if (GetModConfigData("fertile_soil_advantage") == "high") then
TUNING.COMPOSTPILE_FERTILE_SOIL_ADVANTAGE_PERCENT = 0.3
end
-- composting probably allures some fireflies
TUNING.COMPOSTPILE_FIREFLYSPAWN_PERCENT_LOW = 0.05
if (GetModConfigData("spawn_fireflies") == "always") then
TUNING.COMPOSTPILE_FIREFLYSPAWN_PERCENT_LOW = 1
end
if (GetModConfigData("spawn_fireflies") == "off") then
TUNING.COMPOSTPILE_FIREFLYSPAWN_PERCENT_LOW = 0
end
TUNING.COMPOSTPILE_FIREFLYSPAWN_PERCENT_HIGH = 0.95
if (GetModConfigData("spawn_fireflies") == "always") then
TUNING.COMPOSTPILE_FIREFLYSPAWN_PERCENT_HIGH = 1
end
if (GetModConfigData("spawn_fireflies") == "off") then
TUNING.COMPOSTPILE_FIREFLYSPAWN_PERCENT_HIGH = 0
end