Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- width, height = term.getSize() -- gets the screen size
- local progs = {"", "", "" } -- makes a table for use later
- local progsrun = {"", "", "" } -- ^^
- function round(val)
- return math.floor(val + 0.5)
- end -- a simple rounding program
- function getCenter(length) -- A function that is used to find
- length1 = string.len(length) -- the center of the page
- center = width / 2 - length1 / 2
- return center
- end
- function title(title) -- A function that is used to generate the title
- term.setCursorPos(getCenter(title), 1)
- term.write(title)
- term.setCursorPos(1, 2)
- local var pos = 1
- while pos <= width do
- term.setCursorPos(pos, 2)
- term.write("_")
- pos = pos + 1
- end
- end
- function option( optna, optno, totoptno, progtorun, proargs) -- This is the function that is broken somewhere
- local pos = round((height / (totoptno + 1) * optno) + 2 )
- term.setCursorPos(getCenter(optna), pos)
- term.write( optna )
- table.insert(progs, optno, pos) -- This is the table function that im having the problem with as detailed in the OP
- table.insert(progsrun, optno, progtorun) -- The error occurs here too
- -- When activated do
- -- shell.run ( progtorun, progargs )
- end
- function detect() -- Function to control the cursor
- cursorpos = 1
- while true do
- keyPress = os.pullEvent(char)
- if keyPress == 200 then -- detect key presses and if its the down key
- cursorpos = cursorpos - 1 -- reduce the cursor position by 1
- else if keyPress == 208 then -- oes the opposite
- cursorpos = cursorpos + 1
- else sleep(1)
- end
- if cursorpos < table.getn(progs) then
- cursorpos = cursorpos - 1
- end
- secpos = progs[cursorpos] -- looks at the position of the options based on the variable stored in the table from the option function
- term.setCursorPos( 5, secpos) --
- term.write("-->")
- end
- end
- end
- title( " Epic GUI " )
- option( "Portal Song - Still Alive", 1, 3, "play", "" )
- option( "Hey Me", 2, 3, "heyme", "")
- option( "cest bien", 3, 3, "optnamd", "")
- write(progs[1], progs[2]) -- This is how i found where the error was occuring
- detect()
Advertisement
Add Comment
Please, Sign In to add comment