-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigilines.lua
More file actions
116 lines (93 loc) · 2.99 KB
/
digilines.lua
File metadata and controls
116 lines (93 loc) · 2.99 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
ctg_machines.machine_digiline_effector = function(pos, _, channel, msg)
local set_channel = "machine" -- static channel for now
local msgt = type(msg)
if msgt ~= "table" then
return
end
if channel ~= set_channel then
return
end
if msg.command == "enable" then
local meta = core.get_meta(pos)
meta:set_int("enabled", 1)
end
if msg.command == "disable" then
local meta = core.get_meta(pos)
meta:set_int("enabled", 0)
end
end
ctg_machines.electrolysis_digiline_effector = function(pos, _, channel, msg)
local set_channel = "electrolysis" -- static channel for now
local msgt = type(msg)
if msgt ~= "table" then
return
end
if channel ~= set_channel then
return
end
if msg.command == "enable" then
local meta = core.get_meta(pos)
meta:set_int("enabled", 1)
end
if msg.command == "disable" then
local meta = core.get_meta(pos)
meta:set_int("enabled", 0)
end
end
ctg_machines.chem_lab_digiline_effector = function(pos, node, channel, msg)
local meta = core.get_meta(pos)
local set_channel = "chemical_lab" -- static channel for now
local msgt = type(msg)
if msgt ~= "table" then
return
end
if channel ~= set_channel then
return
end
if msg.command == "enable" then
meta:set_int("enabled", 1)
end
if msg.command == "disable" then
meta:set_int("enabled", 0)
end
if msg.command == "set_recipe" then
local recipe = tonumber(msg.recipe)
if recipe then
meta:set_int(recipe)
end
end
if msg.command == "recipe" then
local inv = meta:get_inventory()
local src1 = inv:get_list("src1")
local src2 = inv:get_list("src2")
local src3 = inv:get_list("src3")
local src4 = inv:get_list("src4")
local recipe_index = meta:get_int("recipe")
local recipe_name = ""
if recipe_index == 1 then
recipe_name = "Coolant"
elseif recipe_index == 2 then
recipe_name = "Seed Oil"
end
digilines.receptor_send(pos, digilines.rules.default, set_channel, {
command = msg.command .. "_ack",
pos = core.serialize(pos),
recipe = recipe_index,
recipe_name = recipe_name,
inv1 = src1[1]:get_count(),
inv2 = src2[1]:get_count(),
inv3 = src3[1]:get_count(),
inv4 = src4[1]:get_count(),
has_water = meta:get_int("output_count") > 0,
})
end
if msg.command == "fluid_status" then
digilines.receptor_send(pos, digilines.rules.default, set_channel, {
command = msg.command .. "_ack",
pos = core.serialize(pos),
has_water = meta:get_int("output_count") > 0,
water_count = meta:get_int("output_count"),
water_max = meta:get_int("output_max"),
})
end
end