-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc.lua
More file actions
49 lines (45 loc) · 1.13 KB
/
misc.lua
File metadata and controls
49 lines (45 loc) · 1.13 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
local function GetMaxStage()
print("Enter max growth stage of crop")
repeat
input = io.read()
until tonumber(input) and tonumber(input) > 1
return tonumber(input)
end
local function Initialize()
currentPos.x = fieldCenter
currentPos.y = fieldCenter
for i = 1, fieldLength do
field[i] = {}
end
end
local function SetColor(event)
if event == "error" then r.setLightColor(0xFF0000)
elseif event == "scan" then r.setLightColor(0x0000FF)
elseif event == "care" then r.setLightColor(0x00FF00)
elseif event == "idle" then r.setLightColor(0xFFFFFF)
end
end
local function Charge()
if comp.energy() / comp.maxEnergy() < 0.3 then
print("Charging")
SetColor("idle")
MoveTo(fieldCenter, fieldCenter)
TryMove("bottom")
TryMove("bottom")
os.sleep(timeCharge)
TryMove("top")
TryMove("top")
if comp.energy() / comp.maxEnergy() < 0.9 then
print("Cant charge!")
misc.SetColor("error")
farm.Panic()
end
end
end
misc = {
GetMaxStage = GetMaxStage,
Initialize = Initialize,
SetColor = SetColor,
Charge = Charge
}
return misc