-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheffects_monitor.lua
More file actions
110 lines (101 loc) · 2.48 KB
/
effects_monitor.lua
File metadata and controls
110 lines (101 loc) · 2.48 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
server = 51
order_effect = {}
order = {}
effects = {
[2] = "Fire Resistance",
[3] = "Speed",
[4] = "Night Vision",
[5] = "Water Breathing",
[6] = "Invisibility",
[7] = "Regeneration",
[8] = "Strength"
}
durations = {
[2] = 20,
[3] = 30,
[4] = 30,
[5] = 10,
[6] = 25,
[7] = 5,
[8] = 15
}
effect_color = {
[2] = colors.orange,
[3] = colors.white,
[4] = colors.blue,
[5] = colors.lightBlue,
[6] = colors.lightGray,
[7] = colors.pink,
[8] = colors.red
}
function update_order_effect()
order_effect = {}
for i = 1, getTableSize(order) do
effect = order[i]
if effects[effect] then
if order_effect[effect] then
order_effect[effect][1] = order_effect[effect][1] + 1
else
order_effect[effect] = {[1] = 1, [2] = durations[effect]}
end
else
for j=2,8 do
if order_effect[j] then
order_effect[j][2] = order_effect[j][2] + 120
order_effect[j][1] = order_effect[j][1] - 1
if order_effect[j][1] == 0 then order_effect[j] = nil end
end
end
end
end
end
function write_effects()
bg = colors.black
color_print(colors.black, colors.white, "Effect Preview:")
-- Write 8 lines
if getTableSize(order_effect) == 0 then
color_print(bg, colors.white, "No effect")
print("")
end
for i, v in pairs(order_effect) do
color_print(bg, effect_color[i],
effects[i].." "..v[1].." ("..v[2].."s)")
end
for i=1, 7-#order_effect do
color_print(bg, colors.black, "")
end
end
function color_print(bg, text_color, text)
term.setBackgroundColor(bg)
term.setTextColor(text_color)
x,y = term.getCursorPos()
if #text>18 then print(" ") end
write(" ")
term.setCursorPos(x,y)
print(text)
reset_color()
end
function reset_color()
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
end
function getTableSize(t)
local count = 0
for _, __ in pairs(t) do
count = count + 1
end
return count
end
rednet.open("top")
while true do
term.setCursorPos(1,1)
reset_color()
term.clear()
update_order_effect()
write_effects()
local id = -1
while id ~= server do
id, message = rednet.receive()
end
order = message
end