View difference between Paste ID: 8D4MK4fm and 8y4dbAEn
SHOW: | | - or go back to the newest paste.
1
-- binding peripherals/initializing
2
--((
3
local monitor = peripheral.wrap("top")
4
local modem = peripheral.wrap("back")
5
local me = peripheral.wrap("right")
6
rednet.open("back")
7
-- global variables
8
local essence_tank_capacity = 1000-- storage capacity of the mob essence tank
9
local essence_tank_amount = 0 -- total amount of mob essence in the tank
10
local Mob_essence_on = false -- is the mob essence spawner on
11
local Mob_zpm_on = false -- is the zombypigman spawner on
12
local Mob_skeleton_on = false -- is the skeleton spawner on
13
local Mob_creep_on = false -- is the creeper spawner on
14
local Mob_ender_on = false -- is the enderman spawner on
15
local Mob_zombie_on = false -- is the zombie spawner on
16
local Mob_iron_on = false -- is the iron golem spawner on
17
local Mob_chicken_on = false -- is the chicken spawner on
18
local Mob_cow_on = false -- is the cow spawner on
19
local Mob_sheep_on = false -- is the sheep spawner on
20-
local bones = 0
20+
local bones = 0-- amount of bones in my ME system
21-
local gold = 0
21+
local gold = 0--amount of gold in my ME system
22-
local iron = 0
22+
local iron = 0--amount of iron in my ME system
23
local gunpowder = 0
24
local bonesID =352
25
local goldID = 266
26
local ironID = 265
27
local gunpowderID = 289
28
local bones_max = 1024
29
local gold_max = 1024
30
local iron_max = 1024
31
local gunpowder_max = 1024
32
--))
33
-- get data from tank
34
function essenceupdate()
35
  rednet.broadcast("Send_Essence_Tank_Status");
36
  local senderId, message, distance = rednet.receive(10)
37
  local tbl = textutils.unserialize(message)
38
  if tbl["ID"] == "Essence_Tank_Status" then
39
    essence_tank_amount = tbl["amount"]
40
    essence_tank_capacity = tbl["capacity"]
41
    print(essence_tank_amount)
42
  else
43
    essenceupdate()
44
  end
45
end
46
-- get updated values from my ME system
47
function updateME()
48
  local MEstuff = me.getAvailableItems()
49
  for k, v in pairs(MEstuff) do
50
    if me.getItemID(v[1]) == goldID then
51
      gold = v[2]
52-
    elseif me.getItemID(v[1]) == ironID then
52+
    elseif me.getUnlocalizedName(v[1]) == "Bone" then
53
      iron = v[2]
54
    elseif me.getItemID(v[1]) == bonesID then
55
      bone = v[2]
56
    elseif me.getItemID(v[1]) == gunpowderID then
57
      gunpowder = v[2]
58
    end
59
  end
60
end
61
62
-- function to print the stop/run function on the screen
63
function printstatus(bool)
64
  if bool == true then
65
    monitor.setTextColor(colors.green)
66
    print(" RUN")
67
    monitor.setTextColor(colors.white)
68
  else
69
    monitor.setTextColor(colors.red)
70
    print("STOP")
71
    monitor.setTextColor(colors.white)
72
  end
73
end
74
--print stored values on screen
75
function printessencevalues(x,y)
76
  monitor.setTextColor(colors.black)
77
  print("test")
78
  monitor.setCursorPos(x,y)
79
  if essence_tank_amount > 999 then
80
    if essence_tank_amount > (essence_tank_capacity / 2) then
81
      monitor.setTextColor(colors.green)
82
      print(tostring(essence_tank_amount))
83
    else
84
      monitor.setTextColor(colors.orange)
85
      print(tostring(essence_tank_amount))
86
    end
87
  else
88
    monitor.setTextColor(colors.red)
89
    print(tostring(essence_tank_amount))
90
  end
91
  monitor.setTextColor(colors.white)
92
  monitor.setCursorPos(x+10,y)
93
  print(tostring(essence_tank_capacity))
94
end
95
function drawframe()
96
  term.redirect(monitor)--redirect printing to monitor
97
  term.setCursorBlink(false)
98
  monitor.clear()
99
  monitor.setTextColor(colors.white)
100
  monitor.setBackgroundColor(colors.black)
101
  paintutils.drawLine(1,1,50,1,colors.yellow)--Border
102
  paintutils.drawLine(1,26,50,26,colors.yellow)--Border
103
  paintutils.drawLine(1,1,1,26,colors.yellow)--Border
104
  paintutils.drawLine(50,1,50,26,colors.yellow)--Border
105
  paintutils.drawLine(25,1,25,26,colors.yellow)--table
106
  paintutils.drawLine(30,1,30,26,colors.yellow)--table
107
  paintutils.drawLine(40,1,40,26,colors.yellow)--table
108
  -- set texts
109
  monitor.setCursorPos(2,2)
110
  print("Essence")
111
112
  monitor.setCursorPos(26,2)
113
  printstatus(Mob_essence_on)
114
  printessencevalues(31,2)
115
  monitor.setCursorPos(2,3)
116
  print("Gold")
117
  monitor.setCursorPos(26,3)
118
  printstatus(Mob_zpm_on)
119
  monitor.setCursorPos(31,3)
120
  print(gold)
121
  monitor.setCursorPos(41,3)
122
  print(gold_max)
123
  monitor.setCursorPos(2,4)
124
  print("Bones")
125
  monitor.setCursorPos(26,4)
126
  printstatus(Mob_skeleton_on)
127
  monitor.setCursorPos(31,4)
128
  print(bones)
129
  monitor.setCursorPos(41,4)
130
  print(bones_max)
131
  monitor.setCursorPos(2,5)
132
  print("Gunpowder")
133
  monitor.setCursorPos(26,5)
134
  printstatus(Mob_creep_on)
135
  monitor.setCursorPos(31,5)
136
  print(gunpowder)
137
  monitor.setCursorPos(41,5)
138
  print(gunpowder_max)
139
  monitor.setCursorPos(2,6)
140
  print("iron")
141
  monitor.setCursorPos(26,6)
142
  printstatus(Mob_iron_on)
143
  monitor.setCursorPos(31,6)
144
  print(iron)
145
  monitor.setCursorPos(41,6)
146
  print(iron_max)
147
  term.restore()--restore printing to computer
148
end
149
150
-- inf loop
151
while true do
152
  essenceupdate()
153
  updateME()
154
  drawframe()
155
  sleep(5)
156
end