Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- vim: set filetype=lua:
- if viewportAPI then os.unloadAPI("viewportAPI") end
- os.loadAPI("viewportAPI")
- if buttonAPI then os.unloadAPI("buttonAPI") end
- os.loadAPI("buttonAPI")
- if eventDispatcherAPI then os.unloadAPI("eventDispatcherAPI") end
- os.loadAPI("eventDispatcherAPI")
- t = peripheral.wrap("monitor_0")
- viewportMonitor = viewportAPI.new({term = peripheral.wrap("monitor_0")})
- a = {}
- for i = 1, 10 do
- local row = 1
- local length = (t.getSize() - 1) / 3
- if i > length * row then row = row + 1 end
- a[i] = buttonAPI.new({
- text = tostring(i),
- x = 1 + (i - 1) * 3 - length*(row-1)*3 - bit.brshift(bit.band(row, 2),1),
- y = 1 + 3*(row-1),
- isSticky = false,
- width = 2,
- height = 2
- })
- viewportMonitor:addElement(a[i])
- end
- viewportMonitor:redraw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement