Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Calculator
- x4 = 25
- x4 = x4 + 0
- slc2 = 0
- op = 0
- Eingabe = {}
- function titlebarTaschenrechner()
- term.setCursorPos(1,1)
- term.setBackgroundColor(16385)
- term.setTextColor(1)
- term.clearLine()
- term.setCursorPos(2,1)
- print("[Close]")
- end
- function TaschenrechnerButtonsEinzeln(i,x2,y2)
- num = i
- term.setBackgroundColor(256)
- term.setTextColor(32768)
- term.setCursorPos(x2, y2)
- print(" ")
- term.setCursorPos(x2, y2+1)
- write(" ")
- term.setBackgroundColor(1)
- write(num)
- term.setBackgroundColor(256)
- write(" ")
- term.setCursorPos(x2, y2+2)
- print(" ")
- end
- function TaschenrechnerOperatoren(i2,x3,y3)
- op = i2
- term.setCursorPos(x3,y3)
- term.setBackgroundColor(256)
- term.setTextColor(32768)
- print(" ")
- term.setCursorPos(x3,y3+1)
- write(" ")
- term.setCursorPos(x3+1,y3+1)
- term.setBackgroundColor(1)
- write(op)
- term.setCursorPos(x3+9,y3+1)
- term.setBackgroundColor(256)
- write(" ")
- term.setCursorPos(x3, y3+2)
- print(" ")
- end
- function TaschenrechnerButtonsGesamt() --()
- TaschenrechnerButtonsEinzeln(1,2,3)
- TaschenrechnerButtonsEinzeln(2,6,3)
- TaschenrechnerButtonsEinzeln(3,10,3)
- TaschenrechnerButtonsEinzeln(4,2,7)
- TaschenrechnerButtonsEinzeln(5,6,7)
- TaschenrechnerButtonsEinzeln(6,10,7)
- TaschenrechnerButtonsEinzeln(7,2,11)
- TaschenrechnerButtonsEinzeln(8,6,11)
- TaschenrechnerButtonsEinzeln(9,10,11)
- TaschenrechnerButtonsEinzeln(0,2,15)
- TaschenrechnerButtonsEinzeln("C",6,15)
- TaschenrechnerButtonsEinzeln(">",10,15)
- term.setBackgroundColor(256)
- term.setTextColor(32768)
- term.setCursorPos(24, 3)
- print(" ")
- term.setCursorPos(24,4)
- write(" ")
- term.setBackgroundColor(1)
- write(" ")
- term.setBackgroundColor(256)
- write(" ")
- term.setCursorPos(24,5)
- print(" ")
- TaschenrechnerOperatoren("add ", 24, 9)
- TaschenrechnerOperatoren("subtract", 36,9)
- TaschenrechnerOperatoren("multiply", 24, 14)
- TaschenrechnerOperatoren("divide ", 36, 14)
- end
- function TaschenrechnerErg(i)
- i = x4
- if x4 <= 43 then
- x4 = x4 +1
- elseif x4 >= 43 then
- x4 = x4
- end
- end
- function TaschenrechnerVorspann()
- term.setBackgroundColor(8)
- term.setTextColor(16384)
- shell.run("clear")
- term.setCursorPos(16 , 10)
- print(" Calculator ")
- term.setCursorPos(16,11)
- print("--written by Vali--")
- end
- function TaschenrechnerZahlen(i,x)
- table.insert(Eingabe, i)
- term.setBackgroundColor(1)
- term.setTextColor(32768)
- term.setCursorPos(x,4)
- TaschenrechnerErg(x)
- write(Eingabe)
- end
- function TaschenrechnerOPclear()
- term.setBackgroundColor(1)
- term.setTextColor(32768)
- term.setCursorPos( 25, 4)
- write(" ")
- term.setCursorPos(25, 4)
- end
- TaschenrechnerVorspann()
- sleep(2)
- shell.run("clear")
- TaschenrechnerButtonsGesamt()
- titlebarTaschenrechner()
- while true do
- local event, button, x, y = os.pullEvent()
- if event == "mouse_click" then
- if x >= 2 and x <= 8 and y == 1 and button == 1 then
- shell.run("GUI")
- elseif x >= 2 and x <= 4 and y >= 3 and y <= 5 and button == 1 then
- TaschenrechnerZahlen(1, x4)
- elseif x >= 6 and x <= 8 and y >= 3 and y <= 5 and button == 1 then
- TaschenrechnerZahlen(2, x4)
- elseif x >= 10 and x <= 12 and y >= 3 and y <= 5 and button == 1 then
- TaschenrechnerZahlen(3, x4)
- elseif x >= 2 and x <= 4 and y >=7 and y <= 9 and button == 1 then
- TaschenrechnerZahlen(4, x4)
- elseif x >= 6 and x <= 8 and y >= 7 and y <= 9 and button == 1 then
- TaschenrechnerZahlen(5, x4)
- elseif x >10 and x <= 12 and y >= 7 and y <= 9 and button == 1 then
- TaschenrechnerZahlen(6, x4)
- elseif x >= 2 and x <= 4 and y >= 11 and y <= 13 and button == 1 then
- TaschenrechnerZahlen(7, x4)
- elseif x >= 6 and x <= 8 and y >= 11 and y <= 13 and button == 1 then
- TaschenrechnerZahlen(8, x4)
- elseif x >= 10 and x <= 12 and y >= 11 and y <= 13 and button == 1 then
- TaschenrechnerZahlen(9, x4)
- elseif x >= 2 and x <= 4 and y >= 15 and y <= 17 and button == 1 then
- TaschenrechnerZahlen(0, x4)
- elseif x >= 24 and x <= 34 and y >= 9 and y <= 11 and button == 1 and slc2 == 0 then
- TaschenrechnerZahlen("+", x4)
- slc2 = 1
- op = 1
- elseif x >= 36 and x <= 46 and y >= 9 and y <= 11 and button == 1 and slc2 == 0 then
- TaschenrechnerZahlen("-", x4)
- slc2 = 1
- op = 2
- elseif x >= 24 and y <= 34 and y >= 14 and y <= 16 and button == 1 and slc2 == 0 then
- TaschenrechnerZahlen("*", x4)
- slc2 = 1
- op = 3
- elseif x >= 36 and x <= 46 and y >= 14 and y <= 16 and button == 1 and slc2 == 0 then
- TaschenrechnerZahlen("/", x4)
- slc2 = 1
- op = 4
- elseif x >= 6 and x <= 8 and y >= 15 and y <= 17 and buttons == 1 then
- TaschenrechnerOPclear()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment