Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------
- -- Program: MENU -- Temporal variables: _<type>Varname --
- -- Author: JaggerDer -- Constants: <type>VARNAME --
- -- Created: 11.11.14 -- Argument: a<type>Argname --
- ----------------------------------------------------------------
- --<APIs>--
- --<LOCAL VARIABLES>--
- local tMenuItem = {}
- local iCurrentItem = 0
- --<CONSTANTS>--
- local iMAXITEMS = 0 --{0 - unlimited}
- --[TEXTMENU]--
- function fDrawMenu()
- term.clear()
- local _iMILen = #tMenuItem
- local _sStr = nil
- for i = 1, _iMILen, 1 do
- if (i ~= iCurrentItem+1) then
- _sStr = i .. ": " .. tMenuItem[i]["name"]
- else
- _sStr = i .. ": " .. tMenuItem[i]["name"] .. " <- "
- end
- term.setCursorPos(1, i)
- write(_sStr)
- end
- end
- function fRegisterItem(asName, afFunc)
- local _iMILen = #tMenuItem + 1
- tMenuItem[_iMILen] = {}
- tMenuItem[_iMILen]["name"] = asName
- tMenuItem[_iMILen]["func"] = afFunc
- end
- function fNextItem()
- iCurrentItem = (iCurrentItem + 1) % #tMenuItem
- end
- function fPrevItem()
- iCurrentItem = (iCurrentItem - 1) % #tMenuItem
- end
- function fRunAction()
- local _fFunc = tMenuItem[iCurrentItem+1]["func"]
- _fFunc()
- end
Advertisement
Add Comment
Please, Sign In to add comment