-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServer.lua
294 lines (259 loc) · 8.44 KB
/
Server.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
--[[
BloodCtrl
Automated Blood Magic Slate Creation
Version: 0.1.1
Author: Haybale100
License: CC BY 4.0
How to use: https://oc.cil.li/index.php?/topic/1736-bloodctrl-v01-automated-blood-magic-slate-creation/
]]
-- Variables --
-- You can change these as needed
component = require("component")
transpose = component.transposer
term = require("term")
rs = component.redstone
gpu = component.gpu
sides = require("sides")
colors = require("colors")
event = require("event")
m = component.modem
BloodAltarTier = 4 -- Change manually depending on your Altar level, Default: 5 (Tier: V)
slateBCount = 8 -- Blank Slates, Default: 8
slateRCount = 8 -- Reinforced Slates, Default: 8
slateICount = 8 -- Imbued Slates, Default: 4
slateDCount = 8 -- Demonic Slates, Default: 4
slateECount = 2 -- Etherial Slates, Default: 1
chestSide = sides.north -- Default: sides.top (1)
stoneSide = sides.south -- Default: 2 (Back)
altarSide = sides.left --Default: 4 (Right)
reserveTankSide = sides.left --Default: 5 (Left), this is only used if a tank is detected
rsInputSide = sides.right --Default: 4 (Right), This is right of a computer with a Redstone card or right of a Redstone I/O block
stoneSlot = 1 --Default: 10 (Slot 10 is the first export slot for a Refined Storage Interface, Change this as needed)
-- Altar slots do not need to be changed, unless WayOfTime add additional inventory slots or tanks to the Blood Altar
altarSlot = 1
altarTank = 1
-- Slate Slots below are the first 5 slots of a chest, change these if you are not using any type of regular chest (NOT tested with other mods like Iron Chests)
slateBSlot = 1
slateRSlot = 2
slateISlot = 3
slateDSlot = 4
slateESlot = 5
--|| DON'T CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOUR DOING! ||
-- Global Declares --
stackInfo = {}
itemInfo = {
{
name = "Blank Slate",
blood = 1000,
tier = 1
},
{
name = "Reinforced Slate",
blood = 2000,
tier = 2
},
{
name = "Imbued Slate",
blood = 5000,
tier = 3
},
{
name = "Demonic Slate",
blood = 15000,
tier = 4
},
{
name = "Ethereal Slate",
blood = 30000,
tier = 5
}
}
function SetStackInfoBasic()
stackInfo[1] = transpose.getStackInSlot(chestSide, slateBSlot)
end
function SetStackInfoReinforced()
stackInfo[2] = transpose.getStackInSlot(chestSide, slateRSlot)
end
function SetStackInfoImbued()
stackInfo[3] = transpose.getStackInSlot(chestSide, slateISlot)
end
function SetStackInfoDemonic()
stackInfo[4] = transpose.getStackInSlot(chestSide, slateDSlot)
end
function SetStackInfoEthereal()
stackInfo[5] = transpose.getStackInSlot(chestSide, slateESlot)
end
function SetDefaultStackInfo()
if pcall(SetStackInfoBasic) then ;
else
stackInfo[1].label = itemInfo[1].name
stackInfo[1].size = 0
end
if pcall(SetStackInfoReinforced) then ;
else
stackInfo[2].label = itemInfo[2].name
stackInfo[2].size = 0
end
if pcall(SetStackInfoImbued) then ;
else
stackInfo[3].label = itemInfo[3].name
stackInfo[3].size = 0
end
if pcall(SetStackInfoDemonic) then ;
else
stackInfo[4].label = itemInfo[4].name
stackInfo[4].size = 0
end
if pcall(SetStackInfoEthereal) then ;
else
stackInfo[5].label = itemInfo[5].name
stackInfo[5].size = 0
end
end
function getTankInfo()
tInfo = transpose.getFluidInTank(altarSide)
tankAmount = tInfo[1].amount
tankCapacity = tInfo[1].capacity
tankPercent = (tankAmount / tankCapacity) * 100
if term.isAvailable() then
term.clearLine()
term.write(string.format("Current Blood Level: %.2f %%, %.0d mb / %.0d mb\n", tankPercent, tankAmount, tankCapacity))
end
end
function getReserveTankInfo()
rTInfo = transpose.getFluidInTank(reserveTankSide)
if rTInfo.n > 0 then
rTankAmount = rTInfo[1].amount
rTankCapacity = rTInfo[1].capacity
rTPercent = (rTankAmount / rTankCapacity) * 100
if term.isAvailable() then
term.clearLine()
term.write(string.format("Reserve Blood Level: %.2f %%, %.0d mb / %.0d mb\n", rTPercent, rTankAmount, rTankCapacity))
end
else
if term.isAvailable() then
term.write("No Reserve Tank Detected\n")
end
end
end
function WriteRSBlood()
if term.isAvailable() then
term.clearLine()
term.write("Blood Creation: ")
if rs.getInput(rsInputSide) == 0 then
term.write("True \n")
else
term.write("False\n")
end
end
end
function BlankSlate(Fix)
local crafting = true
--Move 1 stone from Interface to Blood Altar
transpose.transferItem(stoneSide, altarSide, 1, stoneSlot, altarSlot)
while crafting do
writeToTerm()
term.write(itemInfo[1].name.."\n")
if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[1].name then
crafting = false
--Move 1 Blank Slate from Blood Altar to Chest
transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateBSlot)
end
end
Fix = "Ignore patch"
return Fix
end
function ReinforcedSlate(Fix)
local crafting = true
--Move 1 Blank Slate from Chest to Blood Altar
transpose.transferItem(chestSide, altarSide, 1, slateBSlot, altarSlot)
while crafting do
writeToTerm()
term.write(itemInfo[2].name.."\n")
if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[2].name then
crafting = false
--Move 1 Reinforced Slate from Blood Altar to Chest
transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateRSlot)
end
end
Fix = "Ignore patch"
return Fix
end
function ImbuedSlate(Fix)
local crafting = true
--Move 1 Reinforced Slate from Chest to Blood Altar
transpose.transferItem(chestSide, altarSide, 1, slateRSlot, altarSlot)
while crafting do
writeToTerm()
term.write(itemInfo[3].name.."\n")
if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[3].name then
crafting = false
--Move 1 Imbued Slate from Blood Altar to Chest
transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateISlot)
end
end
Fix = "Ignore patch"
return Fix
end
function DemonicSlate(Fix)
local crafting = true
--Move 1 Imbued Slate from Chest to Blood Altar
transpose.transferItem(chestSide, altarSide, 1, slateISlot, altarSlot)
while crafting do
writeToTerm()
term.write(itemInfo[4].name.."\n")
if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[4].name then
crafting = false
--Move 1 Demonic Slate from Blood Altar to Chest
transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateDSlot)
end
end
Fix = "Ignore patch"
return Fix
end
function EtherealSlate(Fix)
local crafting = true
--move 1 Demonic Slate from chest to Blood Altar
transpose.transferItem(chestSide, altarSide, 1, slateDSlot, altarSlot)
while crafting do
if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[5].name then
crafting = false
--Move 1 Ethereal Slate from Blood Altar to Chest
transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateESlot)
end
end
Fix = "Ignore patch"
return Fix
end
function writeToTerm()
term.setCursor(1,1)
getTankInfo()
getReserveTankInfo()
WriteRSBlood()
term.clearLine()
term.write("Making: ")
end
function NetSetup()
m.open(1)
print(m.IsOpen)
m.broadcast(1,"Network Port Open")
local _, _, from, port, _, message = event.pull("modem_message")
end
NetSetup()
while true do
if message == "Slate1"
BlankSlate() then
end
elseif message == "Slate2" then
ReinforcedSlate()
end
elseif message == "Slate3" then
ImbuedSlate()
end
elseif message == "Slate4"
DemonicSlate()
end
elseif message == "Slate5"
EtherealSlate()
end
end