Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xs, ys = term.getSize()
- input = ""
- input2 = ""
- test = ""
- tempinput = ""
- inputpart = 1
- function cwrite(blah, y)
- local x = math.ceil(((xs/2)-(string.len(blah)/2)))
- term.setCursorPos(x,y)
- write(blah)
- end
- cmenu = num
- sid = 0
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function menu(id, text, x, y)
- term.setCursorPos(x, y)
- print(text)
- if sid == id then
- term.setCursorPos(x,y)
- write">"
- else
- term.setCursorPos(x,y)
- write"*"
- end
- end
- while true do
- clear()
- cwrite("===================================",1)
- cwrite("= =",2)
- cwrite(input .. test .. input2,2)
- cwrite("===================================",3)
- cwrite("=======================================",4)
- menu(0,"= 7 =", 6, 5)
- menu(1,"= 8 =", 10, 5)
- menu(2,"= 9 =", 14, 5)
- menu(3,"= 4 =", 6, 6)
- menu(4,"= 5 =", 10, 6)
- menu(5,"= 6 =", 14, 6)
- menu(6,"= 1 =", 6, 7)
- menu(7,"= 2 =", 10, 7)
- menu(8,"= 3 =", 14, 7)
- menu(9,"= - =", 6, 8)
- menu(10,"= 0 =", 10, 8)
- menu(11,"= . =", 14, 8)
- cwrite("=======================================",9)
- sleep(0)
- event, key = os.pullEvent("key")
- if key == 200 then
- if sid > 2 then
- sid = sid - 3
- end
- elseif key == 203 then
- if sid > 0 then
- sid = sid - 1
- end
- elseif key == 205 then
- if sid < 11 then
- sid = sid + 1
- end
- elseif key == 208 then
- if sid <= 11-3 then
- sid = sid + 3
- end
- elseif key == 29 then
- if cmenu == num then
- cmenu = action
- elseif cmenu == action then
- cmenu = num
- end
- end
- if key == 28 then
- if sid == 0 then
- tempinput = tempinput.."7"
- elseif sid == 1 then
- tempinput = tempinput.."8"
- elseif sid == 2 then
- tempinput = tempinput.."9"
- elseif sid == 3 then
- tempinput = tempinput.."4"
- elseif sid == 4 then
- tempinput = tempinput.."5"
- elseif sid == 5 then
- tempinput = tempinput.."6"
- elseif sid == 6 then
- tempinput = tempinput.."1"
- elseif sid == 7 then
- tempinput = tempinput.."2"
- elseif sid == 8 then
- tempinput = tempinput.."3"
- elseif sid == 9 then
- if input2 == "" then
- test = "-"
- inputpart = 2
- tempinput = ""
- else
- if test == "-" then
- answer = tonumber(input) - tonumber(input2)
- input2 = ""
- test = ""
- tempinput = answer
- inputpart = 1
- end
- end
- elseif sid == 10 then
- tempinput = tempinput.."0"
- elseif sid == 11 then
- tempinput = tempinput.."."
- end
- end
- if inputpart == 1 then
- input = tempinput
- else
- input2 = tempinput
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment