Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- essentia reader computer FSM--
- os.loadAPI("button")
- os.loadAPI("melStart")
- m = peripheral.find("monitor")
- p = peripheral.find("EssentiaProvider")
- local x,y,z,v
- local n,a
- local colorsToUse = {colors.green,colors.blue,colors.brown}
- local colorTracker, collumnTracker, rowTracker
- local rowOffset, collumnOffset, collumnOffset2, rowLimit, collumnLimit
- --Set up some important 'local' globals (srsly lua?)
- collumnOffset = 18
- collumnOffset2 = 13 --Used for variable
- rowOffset = 1
- collumnLimit = 3
- rowLimit = 15
- n = -1
- a = 0
- x = 1
- y = 0
- z = y
- lineblank = ""
- aspectNum = 48
- function aspectTable()
- --Grab the nonbeliever table
- local tempList = {p.getAspects()}
- --Now convert (I hope)
- eTable = {}
- local iTemp2 = 0
- for iTemp=1,table.getn(tempList),2 do
- iTemp2 = iTemp2 + 1
- eTable[iTemp2] = {}
- eTable[iTemp2].name = tempList[iTemp]
- eTable[iTemp2].amount = tempList[iTemp+1]
- end
- --Attempt the sorting
- local sort_func = function( a,b ) return a.name < b.name end
- table.sort( eTable, sort_func )
- end
- function aspectDis()
- --Reset trackers
- colorTracker = 0
- collumnTracker = 0
- rowTracker = 0
- --Do out first setup
- --m.setTextColor(colorsToUse[colorTracker])
- for i, result in ipairs( eTable ) do
- --Position the cursor
- m.setCursorPos(1+(collumnOffset*collumnTracker), 1+(rowOffset*rowTracker))
- m.write(result.name)
- m.setCursorPos(collumnOffset2+(collumnOffset*collumnTracker), 1+(rowOffset*rowTracker))
- m.write(":" .. result.amount)
- --Bump down a row
- rowTracker = rowTracker + 1
- --If rowTracker is equal to rowLimit,
- --reset and bump collumnTracker
- if(rowTracker == rowLimit) then
- rowTracker = 0
- collumnTracker = collumnTracker + 1
- --Also set the colorTracker
- colorTracker = colorTracker + 10
- --m.setTextColor(colorsToUse[colorTracker])
- end
- end
- end
- --melStart.startup()
- m.setBackgroundColor(colors.purple)
- m.setTextColor(colors.black)
- m.setTextScale(1.5)
- while true do
- m.clear()
- aspectTable()
- aspectDis()
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement