Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )
- local function txt(x,y,t,c)
- if c then term.setTextColour(c) end
- term.setCursorPos(x,y)
- if type(t) == "string" or type(t) =="number" then
- write(t)
- else
- write(textutils.serialise(t))
- end
- term.setTextColour(colors.white)
- end
- local function stxt(x,y,t,r,c)
- if c then term.setTextColour(c) end
- term.setCursorPos(x,y)
- textutils.slowPrint(t,r)
- term.setTextColour(colors.white)
- end
- local function randomPercent(val)
- if math.random(100) <= val then
- return true
- else
- return false
- end
- end
- local function drawOptionsList(x,y,cursor,list,al)
- for i = 1, #list do
- local cursStr = "["..i.."] "
- local cursCol = al.color
- if i == cursor then
- cursStr = ">"..i.."< "
- cursCol = al.curs
- end
- txt(x,y+i-1,cursStr,cursCol)
- txt(x+#cursStr,y+i-1,list[i],al.color)
- end
- end
- local function updateCursor(list,cursor)
- local _, key = os.pullEvent("key")
- local choice = false
- if key == keys.up or key == keys.numPad8 then
- if cursor > 1 then
- cursor = cursor - 1
- end
- elseif key == keys.down or key == keys.numPad2 then
- if cursor < #list then
- cursor = cursor + 1
- end
- elseif key == keys.enter or key == keys.numPadEnter then
- choice = tonumber(cursor)
- end
- return cursor,choice
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement