Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ps = peripheral.getNames()
- aspects = {}
- pers = {}
- aspectsC = {}
- ex_Aspects = {"ira", "infernus", "gula", "invidia", "desidia", "superbia", "luxuria", "tempus"}
- m = peripheral.wrap("left")
- w,h = m.getSize()
- cols = 3
- colS = w/cols
- h = h-2
- --aspects[num][1] = peripheral.call(per, "getAspects")[1]
- function getA() -- function gets aspects and its values
- for num, per in pairs(ps) do
- type = peripheral.getType(per)
- if type == "tt_aspectContainer" then
- aspect = peripheral.call(per, "getAspects")[1]
- ifNil(aspect,per)
- elseif type== "tilejarvoid" then
- aspect = peripheral.call(per, "getAspects")[1][2]
- ifNil(aspectper)
- end
- end
- end
- function order(arr)
- table.sort(arr)
- for e,l in pairs(arr) do
- ass, pers = l:match("([^,]+),([^,]+)")
- quantity = peripheral.call(pers,"getAspectCount",ass)
- table.insert(aspectsC,{["a"] = ass,["q"] = quantity})
- end
- end
- function ifNil(aspectation,peripheral)
- if aspectation ~= nil then
- table.insert(aspects,aspectation..","..peripheral)
- end
- end
- function fixNumber(number)
- number = tostring(number)
- if(string.len(number) < 2) then
- number = "0"..number
- end
- return number
- end
- function setColor(aspectCount)
- if(aspectCount == 0) then
- m.setTextColor(colors.red)
- elseif((aspectCount < 17) and (aspectCount > 0)) then
- m.setTextColor(colors.yellow)
- elseif((aspectCount < 64) and (aspectCount > 16)) then
- m.setTextColor(colors.cyan)
- elseif(aspectCount == 64) then
- m.setTextColor(colors.green)
- end
- end
- function writeA()-- function writes on the screen
- m.clear()
- m.setCursorPos(1,1)
- height = 1
- col = 0
- for p,j in pairs(aspectsC) do
- setColor(j["q"])
- m.write(j["a"])
- m.setCursorPos((col+1)*(colS-1),height)
- m.write(fixNumber(j["q"]))
- if height > h then
- height = 1
- col = col + 1
- else
- height = height+1
- end
- m.setCursorPos(col*colS+1,height)
- end
- end
- shell.run("clear")
- print("This program will output to the monitor on top the aspects it detects")
- print("Click on the screen to refresh the values")
- while true do
- getA()
- order(aspects)
- writeA()
- local side, x, y = os.pullEvent("monitor_touch")
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment