Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- -- TechOS -- --
- -- Local Variables --
- local nScreenWidth, nScreenHeight = term.getSize()
- local nSelection = 1
- local menustate = "Boot"
- -- End Local Variables --
- -- Local Tables --
- local tMenus = {
- [ "Boot" ] = {
- options = { "Inventory", "Turtles", "Reactor" },
- draw = drawBoot
- },
- [ "Inventory" ] = {
- options = { "Raw Materials", "Refined Materials" },
- draw = drawInventory
- },
- [ "Turtles" ] = {
- options = { "Mining" },
- draw = drawTurtles },
- [ "Reactor" ] = {
- options = { "Control" },
- draw = drawReactor
- }
- }
- -- End Local Tables --
- -- -- Draw Functions -- --
- -- Base Draw Functios --
- function ClearScreen()
- term.clear()
- term.setCursorPos( 1, 1 )
- end
- function PrintCentered( nHeight, sString )
- term.setCursorPos( nScreenWidth/2 - #sString/2, nHeight )
- term.write( sString )
- end
- function PrintLeft( nHeight, sString )
- term.setCursorPos( 1, nHeight )
- term.write( sString )
- end
- function PrintRight( nHeight, sString )
- term.setCursorPos( ( nScreenWidth + 1 ) - #sString, nHeight )
- term.write( sString )
- end
- function PrintTitle( sName )
- PrintCentered( 1, string.rep( "-", ( nScreenWidth + 1 ) ) )
- PrintCentered( 2, string.rep( "-", ( nScreenWidth + 1 ) ) )
- PrintLeft( 3, "-" )
- PrintCentered( 3, sName )
- PrintRight( 3, "-" )
- PrintCentered( 4, string.rep( "-", ( nScreenWidth + 1 ) ) )
- PrintCentered( 5, string.rep( "-", ( nScreenWidth + 1 ) ) )
- for i = 6, ( nScreenHeight - 1 ) do
- PrintLeft( i, "-" )
- PrintRight( i, "-" )
- PrintCentered( nScreenHeight, string.rep( "--", ( nScreenWidth + 1 ) ) )
- end
- end
- -- End Base Draw Functions
- -- Menu Draw Functions --
- function drawBoot()
- PrintTitle( "Boot Menu" )
- for j = 1, 3 do
- if j == nSelection then
- PrintCentered( 11 + ( j - 1 ), "[" .. tMenus["Boot"].options[j] .. "]" )
- else
- PrintCentered( 11 + ( j - 1 ), " " .. tMenus["Boot"].options[j] .. " " )
- end
- end
- end
- function drawInventory()
- PrintTitle( "Inventory Menu" )
- for k = 1, 2 do
- if k == nSelection then
- PrintCentered( 11 + ( k - 1 ), "[" .. tMenus["Inventory"].options[k] .. "]" )
- else
- PrintCentered( 11 + ( k - 1 ), " " .. tMenus["Inventory"].options[k] .. " " )
- end
- end
- end
- -- End Menu Draw Functions --
- -- -- End Draw Functions -- --
- while true do
- ClearScreen()
- -- -- Problem lies here -- --
- -- drawBoot() -- shows changing of selections
- tMenus[menustate].draw() -- doesn't show changing of selections
- local id, nKey = os.pullEvent("key")
- if nKey == 200 and nSelection > 1 then
- nSelection = nSelection - 1
- elseif nKey == 208 and nSelection < #tMenus[menustate].options then
- nSelection = nSelection + 1
- elseif nKey == 28 then
- menustate = tMenus[menustate].options[nSelection]
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment