forked from DSTBoas/Equipment-Control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modmain.lua
184 lines (167 loc) · 4.45 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
local _G = GLOBAL
local require = _G.require
local MOD_EQUIPMENT_CONTROL = {}
MOD_EQUIPMENT_CONTROL.MODNAME = modname
MOD_EQUIPMENT_CONTROL.SPECIALFOOD = require("util/specialfood")
MOD_EQUIPMENT_CONTROL.KEYBINDSERVICE = require("util/keybindservice")(modname)
MOD_EQUIPMENT_CONTROL.STRINGS = require("equipment_control_strings")
MOD_EQUIPMENT_CONTROL.SPAWNING = false
MOD_EQUIPMENT_CONTROL.PICKUP_FILTER = {}
_G.MOD_EQUIPMENT_CONTROL = MOD_EQUIPMENT_CONTROL
require("categories")
local function EntityScriptPostConstruct(self)
local OldRegisterComponentActions = self.RegisterComponentActions
function self:RegisterComponentActions(...)
if _G.MOD_EQUIPMENT_CONTROL.SPAWNING then
return
end
OldRegisterComponentActions(self, ...)
end
end
AddGlobalClassPostConstruct("entityscript", "EntityScript", EntityScriptPostConstruct)
if GetModConfigData("BUTTON_SHOW") then
local Buttons = require "widgets/buttons"
AddClassPostConstruct("widgets/inventorybar", function(self)
self.buttons = self.root:AddChild(Buttons(self.owner, self))
end)
end
-- Don't do this, it's error prone
-- Each file should have its own config check table at the top of the file
local Overrides =
{
autocane =
{
"TOGGLE_AUTO_EQUIP_CANE",
"AUTO_EQUIP_CANE",
},
autolight =
{
"AUTO_EQUIP_LIGHTSOURCE",
},
autoweapon =
{
"TOGGLE_AUTO_EQUIP",
"AUTO_EQUIP_WEAPON",
"AUTO_EQUIP_GLASSCUTTER",
},
autotool =
{
"AUTO_EQUIP_TOOL",
"AUTO_REPEAT_ACTIONS",
},
mousethrough =
{
"AUTO_EQUIP_TOOL",
"FLYING_BIRDS_MOUSETHROUGH",
"ORANGESTAFF_MOUSETHROUGH",
"YELLOWSTAFF_MOUSETHROUGH",
},
woodieregear =
{
"WOODIE_WEREITEM_UNEQUIP",
},
eatconfirmation =
{
"CONFIRM_TO_EAT",
},
telepoof =
{
"TOGGLE_TELEPOOF",
"TELEPOOF_DISABLED",
"TELEPOOF_HOVER",
"TELEPOOF_DOUBLECLICK",
},
filterattack =
{
"ATTACK_FILTER",
},
filterpickup =
{
"AUTO_EQUIP_TOOL",
"PICKUP_FILTER",
"IGNORE_KNOWN_BLUEPRINT",
"PRIOTIZE_VALUABLE_ITEMS",
"PICKUP_IGNORE_FLOWERS",
"PICKUP_IGNORE_FERNS",
"PICKUP_IGNORE_SUCCULENTS",
"PICKUP_IGNORE_MARSH_BUSH",
"MEAT_PRIORITIZATION_MODE",
},
quickactions =
{
"QUICK_ACTION_CAMPFIRE",
"QUICK_ACTION_TRAP",
"QUICK_ACTION_BEEFALO",
"QUICK_ACTION_WALLS",
"QUICK_ACTION_EXTINGUISH",
"QUICK_ACTION_SLURTLEHOLE",
"QUICK_ACTION_FEED_BIRD",
"QUICK_ACTION_WAKEUP_BIRD",
"QUICK_ACTION_IMPRISON_BIRD",
"QUICK_ACTION_BUILD_FOSSIL",
"QUICK_ACTION_DIG",
"QUICK_ACTION_HAMMER",
"QUICK_ACTION_NET",
"QUICK_ACTION_KLAUS_SACK",
"QUICK_ACTION_ATRIUM_GATE",
"QUICK_ACTION_REPAIR_BOAT",
"QUICK_ACTION_PIG_KING",
"QUICK_ACTION_DIRTPILE",
},
autocandybag =
{
"AUTO_CANDYBAG",
},
autohelm =
{
"AUTO_EQUIP_HELM",
},
autoeat =
{
"AUTO_EAT_FOOD",
},
}
for override, confs in pairs(Overrides) do
local loaded = false
for _, conf in pairs(confs) do
if GetModConfigData(conf) then
Overrides[override] = require("overrides/" .. override)
loaded = true
break
end
end
if not loaded then
Overrides[override] = nil
end
end
local function OnPlayerActivated(_, player)
if player ~= _G.ThePlayer then
return
end
player:AddComponent("actioncontroller")
player:AddComponent("eventtracker")
player:AddComponent("itemtracker")
if GetModConfigData("SORT_INVENTORY") or GetModConfigData("SORT_CHEST") then
player:AddComponent("sorter")
end
if GetModConfigData("DAMAGE_ESTIMATION") then
player:AddComponent("damagetracker")
end
for _, override in pairs(Overrides) do
override()
end
end
local function OnWorldPostInit(inst)
inst:ListenForEvent("playeractivated", OnPlayerActivated, _G.TheWorld)
end
AddPrefabPostInit("world", OnWorldPostInit)
-- Pickup filter colors
AddPrefabPostInitAny(function(inst)
if inst and inst.prefab then
if _G.MOD_EQUIPMENT_CONTROL.PICKUP_FILTER[inst.prefab] then
if inst.AnimState then
inst.AnimState:SetMultColour(1, 0, 0, 1)
end
end
end
end)