-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanureMod.lua
More file actions
56 lines (49 loc) · 2.34 KB
/
manureMod.lua
File metadata and controls
56 lines (49 loc) · 2.34 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
--
-- Manure Mod
--
-- By: baron <mve.karlsson@gmail.com>
--
ManureMod = {}
function ManureMod.fertilizeManureArea(x, z, x1, z1, x2, z2, limitToField)
local detailId = g_currentMission.terrainDetailId
local sprayFirstChannel = g_currentMission.sprayFirstChannel
local sprayNumChannels = g_currentMission.sprayNumChannels
local sprayLevelFirstChannel = g_currentMission.sprayLevelFirstChannel
local sprayLevelNumChannels = g_currentMission.sprayLevelNumChannels
local x0, z0, widthX, widthZ, heightX, heightZ = Utils.getXZWidthAndHeight(detailId, x, z, x1, z1, x2, z2)
-- Increment fertilization levels by 1 where solid manure (spray bit 2)
setDensityMaskParams(detailId, "equals", 2)
setDensityCompareParams(detailId, "greater", 0)
addDensityMaskedParallelogram(
detailId,
x0, z0, widthX, widthZ, heightX, heightZ,
g_currentMission.sprayLevelFirstChannel, sprayLevelNumChannels,
detailId,
g_currentMission.sprayFirstChannel, sprayNumChannels,
1
)
setDensityMaskParams(detailId, "greater", 0)
-- Remove visible fertilizer layer
setDensityParallelogram(
detailId,
x0, z0, widthX, widthZ, heightX, heightZ,
sprayFirstChannel, sprayNumChannels,
0
)
setDensityCompareParams(detailId, "greater", -1)
end
-- Install manure mod.
-- When relying on alphabetical loading order and doing this after loadMission00Finished
-- we hope to overwrite after choppedStraw does to make sure manure was not already deleted
Mission00.loadMission00Finished = Utils.appendedFunction(Mission00.loadMission00Finished, function(...)
local oldUpdateCultivatorArea = Utils.updateCultivatorArea
Utils.updateCultivatorArea = function(x, z, x1, z1, x2, z2, limitToField, limitGrassDestructionToField, angle)
ManureMod.fertilizeManureArea(x, z, x1, z1, x2, z2, limitToField)
return oldUpdateCultivatorArea(x, z, x1, z1, x2, z2, limitToField, limitGrassDestructionToField, angle)
end
local oldUpdatePloughArea = Utils.updatePloughArea
Utils.updatePloughArea = function(x, z, x1, z1, x2, z2, limitToField, limitGrassDestructionToField, angle)
ManureMod.fertilizeManureArea(x, z, x1, z1, x2, z2, limitToField)
return oldUpdatePloughArea(x, z, x1, z1, x2, z2, limitToField, limitGrassDestructionToField, angle)
end
end)