local x, y = term.getSize()
local currentX = 1;
local currentY = 1;
local Cursor = ">";
local pressed = false;
local running = "blank";
function blank()
end
function start()
newLine(1, x-10, "----------+")
newLine(11, x-9, "|")
newLine(11, x-8, "|")
newLine(11, x-7, "|")
newLine(11, x-6, "|")
newLine(11, x-5, "|")
newLine(11, x-4, "|")
newLine(11, x-3, "|")
end
function run(runn31er)
runn31er()
end
function newButton(x1, y1, title, do22)
term.setCursorPos(x1+1, y1)
write(title)
if pressed == true then
if currentX == x1 then
if currentY == y1 then
running = do22
end
end
end
end
function newLine(x1, y1, title)
term.setCursorPos(x1, y1)
if title == "stretch" then
print("--------------------------------------------------")
else
write(title)
end
end
function drawButtons()
newLine(1, y-1, "stretch")
newButton(1, y, "Start", start)
end
function reDraw()
term.clear()
drawButtons()
run(running)
term.setCursorPos(currentX, currentY)
write(Cursor)
end
while true do
reDraw()
local e,key = os.pullEvent( "key" )
if key == 17 or key == 200 then --up
currentY = currentY -1
reDraw()
elseif key == 31 or key == 208 then --down
currentY = currentY +1
reDraw()
elseif key == 203 or key == 30 then --left
currentX = currentX -1
reDraw()
elseif key == 205 or key == 32 then --right
currentX = currentX +1
reDraw()
elseif key == 28 then
pressed = true;
reDraw()
sleep(0.0001)
pressed = false;
end
end
I'm getting a attempt to call string error at line 23 (shown below)
function run(runn31er)
runn31er()
end
I don't have a function called runn31er() but it's supposed to run what you want it to run. For example:
function derp()
print("Hi")
end
run(derp)
Will print "Hi"