Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function numberSelector()
- local function selectNext(newSelect)
- if newSelect >= 1 and newSelect <= 16 then
- turtle.select(newSelect)
- end
- end
- local function ifKey(events,nKey,fn,...)
- if events[1] == "key" and events[2] == tonumber(nKey) then
- fn(...)
- end
- end
- local bRunning = true
- while bRunning do
- local events = { os.pullEvent("key") }
- local newSelect
- local selected = turtle.getSelectedSlot()
- ifKey(events,203,function() newSelect = selected - 1 ; selectNext(newSelect) ; end)
- ifKey(events,205,function() newSelect = selected + 1 ; selectNext(newSelect) ; end)
- ifKey(events,200,function() newSelect = selected - 4 ; selectNext(newSelect) ; end)
- ifKey(events,208,function() newSelect = selected + 4 ; selectNext(newSelect) ; end)
- ifKey(events,28,function() bRunning = false ; end)
- for i = 2,13 do
- ifKey(events,i,function() selectNext(i-1) end)
- end
- for i = 26,27 do
- ifKey(events,i,function() selectNext(i-13) end)
- end
- for i = 39,40 do
- ifKey(events,i,function() selectNext(i-24) end)
- end
- end
- return turtle.getSelectedSlot()
- end
- print(numberSelector())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement