Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- --Killing Floor Monitor by neonerZ v1.0
- --http://youtube.com/neonerz
- --
- --Variables
- rednet.open("back")
- defaultMonColor=colors.black
- m = peripheral.wrap("front")
- m.clear()
- m.setBackgroundColor(defaultMonColor)
- --Draw a box on the monitor
- function drawBox(xpos, ypos, height, width, title, bcolor, tcolor, tbcolor)
- -- if xpos == 1 then xpos=2 end
- -- if ypos == 1 then ypos=2 end
- if ypos > height then height = height+ypos end
- if xpos > width then rwidth = xpos+width -2 else rwidth = width end
- for h = ypos,height+1 do
- for i = xpos,rwidth+1 do
- m.setCursorPos(i,h)
- m.setBackgroundColor(bcolor)
- m.write(" ")
- end
- end
- titleCount = #title
- titlePos = math.floor((width-titleCount)/2)+xpos
- m.setBackgroundColor(tbcolor)
- m.setTextColor(tcolor)
- m.setCursorPos(titlePos,ypos)
- m.write(title)
- m.setBackgroundColor(defaultMonColor)
- h=nil
- i=nil
- end
- --Draw text on the monitor
- function drawText(xpos,ypos,tcolor,bcolor,text)
- m.setCursorPos(xpos,ypos)
- m.setTextColor(tcolor)
- m.setBackgroundColor(bcolor)
- m.write(text)
- m.setBackgroundColor(defaultMonColor)
- end
- --Save total amount of enchants
- function saveEnchantNum()
- local num
- local h
- if fs.exists("enchantAmount") then
- h = fs.open("enchantAmount","r")
- num = h.readLine()
- num = num+1
- h.close()
- h = fs.open("enchantAmount", "w")
- h.write(tostring(num))
- h.close()
- else
- h = fs.open("enchantAmount", "w")
- h.write(1)
- h.close()
- end
- end
- --Read total amount of enchants
- function readEnchantNum()
- if fs.exists("enchantAmount") then
- local num
- local h
- h = fs.open("enchantAmount","r")
- return h.readLine()
- else
- return 0
- end
- end
- --Build GUI
- drawBox(3,2,10,21,"Enchanting",colors.blue,colors.white,colors.black)
- drawBox(28,2,10,21,"Spawner Info",colors.blue,colors.white,colors.black)
- drawBox(25,1,12,1,"",colors.lightGray,colors.white,colors.black)
- drawText(4,4,colors.white,colors.blue,"Level: 0")
- drawText(4,6,colors.white,colors.blue,"Total Enchants: "..readEnchantNum())
- drawText(4,10,colors.white,colors.blue,"waiting...")
- while true do
- --Start waiting for rednet message
- local event, senderID, message, distance = os.pullEvent("rednet_message")
- message = textutils.unserialize(message)
- --Display Level messages
- if message.mode =="level" and message.name=="enchanter01" then
- drawText(4,4,colors.white,colors.blue,"Level: "..message.message)
- drawText(4,8,colors.red,colors.blue," ")
- end
- --Info messages
- if message.mode =="info" and message.name=="enchanter01" then
- drawBox(3,2,10,21,"Enchanting",colors.blue,colors.white,colors.black)
- drawText(4,10,colors.white,colors.blue,message.message)
- if message.message == "Book en route" then
- saveEnchantNum()
- end
- drawText(4,6,colors.white,colors.blue,"Total Enchants: "..readEnchantNum())
- end
- --Error messages
- if message.mode =="error" and message.name=="enchanter01" then
- drawText(4,8,colors.red,colors.blue,message.message)
- end
- -- print("Name: "..message.name)
- -- print("Mode: "..message.mode)
- -- print("Message: "..message.message)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement