Repository navigation
Expand file tree
/
Copy pathWPToolKit.lua
More file actions
126 lines (94 loc) · 3.47 KB
/
Copy pathWPToolKit.lua
File metadata and controls
126 lines (94 loc) · 3.47 KB
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
--
-- WPToolKit
-- A collection of tools for a private server
--
-- @author WPCom
-- @date 03/05/2021
--
WPToolKit = {}
addModEventListener(WPToolKit)
function WPToolKit:loadMap(name)
WPToolKit.events = {}
Player.registerActionEvents = Utils.appendedFunction(Player.registerActionEvents, WPToolKit.registerActionEvents);
Player.updateActionEvents = Utils.appendedFunction(Player.updateActionEvents, WPToolKit.registerActionEvents);
Player.removeActionEvents = Utils.appendedFunction(Player.removeActionEvents, WPToolKit.removeActionEvents);
Enterable.onRegisterActionEvents = Utils.appendedFunction(Enterable.onRegisterActionEvents, WPToolKit.registerActionEvents);
WPToolKit.speedForwardIsRunning = false
WPToolKit.strongIsEnabled = false
WPToolKit.DEFAULT_PICKABLE_MASS = Player.MAX_PICKABLE_OBJECT_MASS
end;
function WPToolKit:removeActionEvents()
WPToolKit.events = {}
end;
function WPToolKit:registerActionEvents()
WPToolKit.events = {}
local result, eventName = InputBinding.registerActionEvent(g_inputBinding, "STRONGFARMER", self, WPToolKit.toggleStrongFarmer, false, true, false, true)
if result then
table.insert(WPToolKit.events, eventName)
g_inputBinding:setActionEventTextVisibility(eventName, true)
g_inputBinding:setActionEventTextPriority(eventName, GS_PRIO_NORMAL)
end
end;
function WPToolKit:toggleStrongFarmer(actionName, keyStatus, arg3, arg4, arg5)
if actionName == "STRONGFARMER" then
if WPToolKit.strongIsEnabled then
Player.MAX_PICKABLE_OBJECT_MASS = WPToolKit.DEFAULT_PICKABLE_MASS;
WPToolKit.strongIsEnabled = false
else
Player.MAX_PICKABLE_OBJECT_MASS = 999
WPToolKit.strongIsEnabled = true
end
end
end;
function WPToolKit:deleteMap()
end;
function WPToolKit:keyEvent(unicode, sym, modifier, isDown)
end;
function WPToolKit:mouseEvent(posX, posY, isDown, isUp, button)
end;
function WPToolKit:update(dt)
-- IF IT IS 8PM AND THE MOD IS NOT RUNNING
if not self.speedForwardIsRunning then
if g_currentMission.environment.currentHour == 20 then
-- START THE MOD
self.speedForwardIsRunning = true
self.speedForward()
end;
-- IF IT IS 6AM AND THE MOD IS RUNNING
elseif self.speedForwardIsRunning and g_currentMission.environment.currentHour == 6 then
-- STOP THE MOD
self.speedStop()
self.speedForwardIsRunning = false
end;
end;
function WPToolKit:draw()
end;
function WPToolKit:keyEvent(unicode, sym, modifier, isDown)
end;
function WPToolKit:speedForward()
-- SAVE PREVIOUS TIME SCALE
WPToolKit.lastTimeScale = g_currentMission.missionInfo.timeScale
WPToolKit.lastGrowthScale = g_currentMission.missionInfo.plantGrowthRate
-- LOWER THE PLANT GROWTH AND UP THE TIME SCALE
g_currentMission.missionInfo.plantGrowthRate = 2.0
g_currentMission.missionInfo.timeScale = 60.0
end;
function WPToolKit:speedStop()
-- LOWER THE PLANT GROWTH AND UP THE TIME SCALE
g_currentMission.missionInfo.plantGrowthRate = WPToolKit.lastGrowthScale
g_currentMission.missionInfo.timeScale = WPToolKit.lastTimeScale
end;
function debugTableLogOutput(table, seperator, depth, maxDepth)
seperator = seperator or "."
depth = depth or 0
maxDepth = maxDepth or 5
if maxDepth == depth then
return
end
for i,j in pairs(table) do
print("[WPToolKit][debugTableLogOutput] "..seperator..tostring(i).." :: "..tostring(j))
if type(j) == "table" then
debugTableLogOutput(j, seperator..".", depth + 1, maxDepth)
end
end
end;