Untitled

                Never    
Lua
       
-- Define a whole load of stuff for the functions
time = 0
selection = 0
UIState = 0
termX, termY = term.getSize()

local arrowUp = 200
local arrowDown = 208
local enter = 28
local keys = {arrowUp, arrowDown, enter}



-- A key was pressed, what do we do?
function keyPressed()
  if (key == arrowUp)
  then
     selectionIncrement()
  end
  if (key == arrowDown)
  then
    selectionDeincrement()
  end
  if (key == enter)
  then
    enterSelection()
  end 
end

-- Increment
function selectionIncrement()
  local S = selection
  selection = (S + 1)
  if (selection > 2)
  then
    selection = 0
  end
  updateUI(UIState, selection)
end

-- Deincrement
function selectionDeincrement()
  local S = selection
  selection = (S - 1)
  if (selection < 0)
  then
    selection = 2
  end
  updateUI(UIState, selection)
end

-- Enter a UI
function enterSelection()
  UIState = selection
  updateUI(UIState, selection)
end

-- wait for a key to be pressed
function getKeyPress()
keyRead = true
  while(keyRead) do
    local keyEvent, key = os.pullEvent("key")
    if (keyEvent == "key")
    then
      for i = 1, #keys, 1 do
        if (key == keys[i])
        then
          keyPressed(key)
          break
        end
      end
    end
  end
end

-- Updating the UI (This is going to be a lot)
function updateUI()

end

-- This is the general  update loop
-- This acts as a global timer and 
-- threading handler
function userLoop()
end

function timerLoop()
end


function loop()
parallel.waitForAny(timerLoop(), userLoop())
  loop()
end

Raw Text