Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while state ~= "Ready" do
- clear()
- if(state == "Editing") then
- drawTempButton(tempButtons["Clear"]["x1"],tempButtons["Clear"]["x2"],tempButtons["Clear"]["y1"],tempButtons["Clear"]["y2"],colors.gray,"Clear")
- drawTempButton(tempButtons["Undo"]["x1"],tempButtons["Undo"]["x2"],tempButtons["Undo"]["y1"],tempButtons["Undo"]["y2"],colors.gray,"Undo")
- drawTempButton(tempButtons["Confirm"]["x1"],tempButtons["Confirm"]["x2"],tempButtons["Confirm"]["y1"],tempButtons["Confirm"]["y2"],colors.gray,"Confirm")
- drawCurrentButton()
- drawButtons()
- elseif(state == "Grid") then
- drawGrid()
- drawButtons()
- elseif(state == "Wrong_monitor_size") then
- m.setCursorPos(1,1)
- m.write("This size")
- m.setCursorPos(1,2)
- m.write("isnt supported")
- elseif(state == "Monitor_resize") then
- a,b = m.getSize()
- yspot = math.floor(b/2)
- xspot = math.floor((1 + a - 25)/2) + 1
- m.setCursorPos(xspot,yspot-1)
- m.write("You resized the monitor,")
- m.setCursorPos(xspot,yspot)
- m.write("return to the old size")
- m.setCursorPos(xspot,yspot+1)
- m.write("or restart this program")
- end
- event = { os.pullEvent() }
- if(event[1] == "monitor_resize") then
- a,b = m.getSize()
- if(a == 15 or b == 15) then
- state = "Wrong_monitor_size"
- elseif(a ~= x or b ~= y) then
- state = "Monitor_resize"
- elseif(a == x and b == y) then
- state = "Grid"
- end
- elseif(event[1] == "monitor_touch") then
- if(state == "Grid") then
- if not checkLine(event[3],event[4]) then
- makeCurrentButton()
- state = "Editing"
- end
- elseif(state == "Editing") then
- result = checkxy(event[3], event[4], tempButtons)
- if(result == "Clear") then
- state = "Grid"
- elseif(result == "Undo") then
- copy(last,current)
- drawCurrentButton()
- elseif(result == "Confirm") then
- term.clear()
- clear()
- term.setCursorPos(1,1)
- yspot = math.floor(y/2)
- xspot = math.floor((1 + x - 25)/2) + 1
- m.setCursorPos(15,15)
- m.write("Plz fill the name into the terminal")
- write("Whats the label of the button? ")
- name = io.read()
- makeButton(name)
- term.setCursorPos(1,2)
- write("Do you want to add another button?[Y/n] ")
- another = io.read()
- if(another ~= "n") then
- state = "Grid"
- else
- state = "Ready"
- result = false
- while not result do
- result = finish()
- end
- end
- elseif(result ~= "none") then
- editButton(result)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement