Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Num's main base computer + HUD
- function update()
- while true do
- updateClock()
- updateStatus()
- sleep(0.05)
- end
- end
- function chatEvents()
- while true do
- evt, msg = os.pullEvent("chat_command")
- words = {}
- wordCount = 0
- for word in string.gmatch(msg, "%S+") do
- words[wordCount] = word
- wordCount = wordCount + 1
- end
- if(words[0]) == "get" then
- if(wordCount == 3 and tonumber(words[1]) ~= nil) then
- placeItemRequest(tonumber(words[1]), words[2])
- else
- newStatus("Invalid command!", 3)
- end
- else
- newStatus("Invalid command!", 3)
- end
- end
- end
- function rednetEvents()
- while true do
- id, msg = rednet.receive()
- words = {}
- wordCount = 0
- for word in string.gmatch(msg, "%S+") do
- words[wordCount] = word
- wordCount = wordCount + 1
- end
- msgColorCode = tonumber(words[0])
- msgText = words[1]
- for i = 2, wordCount-1 do
- msgText = msgText .. " " .. words[i]
- end
- newStatus(msgText, msgColorCode)
- end
- end
- function placeItemRequest(num, item)
- if(num <= 0) then
- newStatus("Number too low!", 3)
- return
- end
- if(num > 256) then
- newStatus("Number too high!", 3)
- return
- end
- rednet.send(14, num.." "..item, true)
- end
- function updateClock()
- time = os.time()
- clock.setText(textutils.formatTime(time, false))
- if(time > 6) then time = time - 6
- else time = time + 18 end
- if(time > 0 and time < 12) then daytime = true
- else daytime = false end
- if(not daytime) then time = time - 12 end
- gameHoursTil = 12 - time
- irlSecondsTil = math.floor(gameHoursTil*50)
- remainStr = math.floor(irlSecondsTil/60) .. ":"
- if(irlSecondsTil%60 < 10) then remainStr = remainStr .. "0" end
- remainStr = remainStr .. irlSecondsTil%60 .. " IRL until "
- if(daytime) then remainStr = remainStr .. "dusk"
- else remainStr = remainStr .. "dawn" end
- remain.setText(remainStr)
- end
- function updateStatus()
- if(statusLife > 0 and not displayingStatus) then activateStatus()
- elseif(statusLife <= 0 and displayingStatus) then deactivateStatus() end
- if(statusLife > 0) then statusLife = statusLife - 1 end
- end
- function newStatus(msg, colorCode)
- statusStr5 = statusStr4
- statusStr4 = statusStr3
- statusStr3 = statusStr2
- statusStr2 = statusStr1
- statusStr1 = msg
- if(colorCode == 1) then status1.setColor(green)
- elseif(colorCode == 2) then status1.setColor(yellow)
- elseif(colorCode == 3) then status1.setColor(red) end
- activateStatus()
- end
- function activateStatus()
- status1.setText(statusStr1)
- status2.setText(statusStr2)
- status3.setText(statusStr3)
- status4.setText(statusStr4)
- status5.setText(statusStr5)
- statusBox.setOpacity2(0.5)
- statusLife = statusLifespan
- displayingStatus = true
- end
- function deactivateStatus()
- status1.setText("")
- status2.setText("")
- status3.setText("")
- status4.setText("")
- status5.setText("")
- statusBox.setOpacity2(0)
- displayingStatus = false
- end
- -----------------------------
- rednet.open("top")
- br = peripheral.wrap("left")
- br.clear()
- daytime = true
- gameHoursTil = 0
- irlSecondsTil = 0
- remainStr = "0:00 IRL until dusk"
- statusLife = 0
- statusLifespan = 200
- displayingStatus = false
- statusStr5 = ""
- statusStr4 = ""
- statusStr3 = ""
- statusStr2 = ""
- statusStr1 = ""
- green = 0x21D928
- yellow = 0xF0DE16
- red = 0xE00000
- title = br.addText(5, 15, "Num FTB Unleashed", 0xFFFFFF)
- shader = br.addText(5, 25, "Shader pack: Sasukedll7170's v7 Ultra", 0xAAAAAA)
- shader.setScale(0.5)
- texture = br.addText(5, 30, "Texture pack: Soartex Fanver", 0xAAAAAA)
- texture.setScale(0.5)
- clock = br.addText(5, 50, "00:00 AM", 0xFFFFFF)
- clock.setScale(0.9)
- remain = br.addText(5, 60, remainStr, 0xAAAAAA)
- remain.setScale(0.5)
- infoBox = br.addGradientBox(0, 13, br.getStringWidth(shader.getText())*0.5+25, 23, 0x000000, 0, 0x000000, 0.5, 2)
- clockBox = br.addGradientBox(0, 48, br.getStringWidth(remain.getText())*0.5+15, 18, 0x000000, 0, 0x000000, 0.5, 2)
- status5 = br.addText(5, 90, "", 0xAAAAAA)
- status5.setScale(0.7)
- status4 = br.addText(5, 97, "", 0xAAAAAA)
- status4.setScale(0.7)
- status3 = br.addText(5, 104, "", 0xAAAAAA)
- status3.setScale(0.7)
- status2 = br.addText(5, 111, "", 0xAAAAAA)
- status2.setScale(0.7)
- status1 = br.addText(5, 118, "", 0x21D928)
- statusBox = br.addGradientBox(0, 88, 140, 39, 0x000000, 0, 0x000000, 0, 2)
- infoBox.setZIndex(1)
- clockBox.setZIndex(1)
- statusBox.setZIndex(1)
- title.setZIndex(2)
- shader.setZIndex(2)
- texture.setZIndex(2)
- clock.setZIndex(2)
- remain.setZIndex(2)
- status5.setZIndex(2)
- status4.setZIndex(2)
- status3.setZIndex(2)
- status2.setZIndex(2)
- status1.setZIndex(2)
- parallel.waitForAny(update, chatEvents, rednetEvents)
Advertisement
Add Comment
Please, Sign In to add comment