Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- v 1.01
- -- [bugfixek] --
- -- first release: 2015.10.09 --
- local ujverzio
- local regiverzio
- local mouseWidth = 0
- local mouseHeight = 0
- local t1 = {}
- local t2 = {}
- local index = 0
- local index2 = 0
- local szam = 0
- local szam2 = 0
- local num1 = 0
- local num2 = 0
- local num3 = 0
- local number1 = 0
- local number2 = 0
- local number3 = 0
- local action = ""
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function updateStartup()
- clear()
- shell.run("pastebin","get","DuQCkwAz","update")
- local file = fs.open("update", "r")
- lx = file.readLine()
- s1 = lx:find("v")
- ujverzio = tonumber(lx:sub(s1+2))
- file.close()
- clear()
- print("Uj verzio: ", ujverzio)
- sleep(1)
- local file = fs.open("startup", "r")
- lx = file.readLine()
- s1 = lx:find("v")
- regiverzio = tonumber(lx:sub(s1+2))
- file.close()
- print("regi verzio: ", regiverzio)
- sleep(1)
- if regiverzio < ujverzio or regiverzio > ujverzio then
- fs.delete("startup")
- fs.copy("update", "startup")
- fs.delete("update")
- shell.run("startup")
- else
- fs.delete("update")
- clear()
- print("nincs elerheto frissites")
- sleep(1)
- return false
- end
- end
- updateStartup()
- m = peripheral.wrap("top")
- m2 = peripheral.wrap("right")
- m.clear()
- m.setCursorPos(1,1)
- w,h=m.getSize()
- print(w)
- print(h)
- function kiir2()
- m2.clear()
- m2.setCursorPos(3,2)
- m2.setTextScale(4)
- m2.write(op)
- end
- function kiir()
- m.setBackgroundColour((colours.red))
- m.setCursorPos(12,4)
- m.write("(")
- m.setCursorPos(14,4)
- m.write(")")
- m.setCursorPos(16,4)
- m.write("%")
- m.setCursorPos(18,4)
- m.write("C")
- m.setCursorPos(12,6)
- m.write("7")
- m.setCursorPos(14,6)
- m.write("8")
- m.setCursorPos(16,6)
- m.write("9")
- m.setCursorPos(18,6)
- m.write("/")
- m.setCursorPos(12,8)
- m.write("4")
- m.setCursorPos(14,8)
- m.write("5")
- m.setCursorPos(16,8)
- m.write("6")
- m.setCursorPos(18,8)
- m.write("*")
- m.setCursorPos(12,10)
- m.write("1")
- m.setCursorPos(14,10)
- m.write("2")
- m.setCursorPos(16,10)
- m.write("3")
- m.setCursorPos(18,10)
- m.write("-")
- m.setCursorPos(12,12)
- m.write("0")
- m.setCursorPos(14,12)
- m.write(".")
- m.setCursorPos(16,12)
- m.write("=")
- m.setCursorPos(18,12)
- m.write("+")
- m.setBackgroundColour((colours.black))
- end
- function muvelet()
- kiir()
- local event, button, X, Y = os.pullEvent("monitor_touch")
- XY = X..","..Y
- m.setCursorPos(1,12)
- m.write(X..","..Y)
- if index == 0 then
- print("indexures")
- m.clear()
- end
- if XY == "12,12" then
- index = index + 1
- table.insert(t1, index, 0)
- m.setBackgroundColour((colours.blue))
- m.setCursorPos(index,1)
- m.write("0")
- print(t1[index])
- elseif XY == "12,10" then
- index = index + 1
- table.insert(t1, index, 1)
- m.setBackgroundColour((colours.blue))
- m.setCursorPos(index,1)
- m.write("1")
- print(t1[index])
- elseif XY == "14,10" then
- index = index + 1
- table.insert(t1, index, 2)
- m.setBackgroundColour((colours.blue))
- m.setCursorPos(index,1)
- m.write("2")
- print(t1[index])
- elseif XY == "16,10" then
- index = index + 1
- table.insert(t1, index, 3)
- m.setBackgroundColour((colours.blue))
- m.setCursorPos(index,1)
- m.write("3")
- print(t1[index])
- elseif XY == "12,8" then
- index = index + 1
- table.insert(t1, index, 4)
- m.setBackgroundColour((colours.blue))
- m.setCursorPos(index,1)
- m.write("4")
- print(t1[index])
- elseif XY == "14,8" then
- index = index + 1
- table.insert(t1, index, 5)
- m.setBackgroundColour((colours.blue))
- m.setCursorPos(index,1)
- m.write("5")
- print(t1[index])
- elseif XY == "16,8" then
- index = index + 1
- table.insert(t1, index, 6)
- m.setBackgroundColour((colours.blue))
- m.setCursorPos(index,1)
- m.write("6")
- print(t1[index])
- elseif XY == "12,6" then
- index = index + 1
- table.insert(t1, index, 7)
- m.setBackgroundColour((colours.blue))
- m.setCursorPos(index,1)
- m.write("7")
- print(t1[index])
- elseif XY == "14,6" then
- index = index + 1
- table.insert(t1, index, 8)
- m.setBackgroundColour((colours.blue))
- m.setCursorPos(index,1)
- m.write("8")
- print(t1[index])
- elseif XY == "16,6" then
- index = index + 1
- table.insert(t1, index, 9)
- m.setBackgroundColour((colours.blue))
- m.setCursorPos(index,1)
- m.write("9")
- print(t1[index])
- elseif XY == "18,12" then
- action = "+"
- m.setCursorPos(17,1)
- m.write(" +")
- print(action)
- muvelet2()
- elseif XY == "18,10" then
- action = "-"
- m.setCursorPos(17,1)
- m.write(" -")
- print(action)
- muvelet2()
- elseif XY == "18,8" then
- m.setCursorPos(17,1)
- m.write(" *")
- action = "*"
- print(action)
- muvelet2()
- elseif XY == "18,6" then
- action = "/"
- m.setCursorPos(17,1)
- m.write(" /")
- print(action)
- muvelet2()
- end
- end
- function muvelet2()
- print("muv2")
- local event, button, X, Y = os.pullEvent("monitor_touch")
- XY = X..","..Y
- m.setCursorPos(1,12)
- m.write(X..","..Y)
- if XY == "12,12" then
- index2 = index2 + 1
- table.insert(t2, index2, 0)
- m.setBackgroundColour((colours.lightBlue))
- m.setCursorPos(index2,2)
- m.write("0")
- print("muv2", t2[index2])
- muvelet2()
- elseif XY == "12,10" then
- index2 = index2 + 1
- table.insert(t2, index2, 1)
- m.setBackgroundColour((colours.lightBlue))
- m.setCursorPos(index2,2)
- m.write("1")
- print(t2[index2])
- muvelet2()
- elseif XY == "14,10" then
- index2 = index2 + 1
- table.insert(t2, index2, 2)
- m.setBackgroundColour((colours.lightBlue))
- m.setCursorPos(index2,2)
- m.write("2")
- print(t2[index2])
- muvelet2()
- elseif XY == "16,10" then
- index2 = index2 + 1
- table.insert(t2, index2, 3)
- m.setBackgroundColour((colours.lightBlue))
- m.setCursorPos(index2,2)
- m.write("3")
- print(t2[index2])
- muvelet2()
- elseif XY == "12,8" then
- index2 = index2 + 1
- table.insert(t2, index2, 4)
- print(t2[index2])
- m.setBackgroundColour((colours.lightBlue))
- m.setCursorPos(index2,2)
- m.write("4")
- muvelet2()
- elseif XY == "14,8" then
- index2 = index2 + 1
- table.insert(t2, index2, 5)
- m.setBackgroundColour((colours.lightBlue))
- m.setCursorPos(index2,2)
- m.write("5")
- print(t2[index2])
- muvelet2()
- elseif XY == "16,8" then
- index2 = index2 + 1
- table.insert(t2, index2, 6)
- m.setBackgroundColour((colours.lightBlue))
- m.setCursorPos(index2,2)
- m.write("6")
- print(t2[index2])
- muvelet2()
- elseif XY == "12,6" then
- index2 = index2 + 1
- table.insert(t2, index2, 7)
- m.setBackgroundColour((colours.lightBlue))
- m.setCursorPos(index2,2)
- m.write("7")
- print(t2[index2])
- muvelet2()
- elseif XY == "14,6" then
- index2 = index2 + 1
- table.insert(t2, index2, 8)
- m.setBackgroundColour((colours.lightBlue))
- m.setCursorPos(index2,2)
- m.write("8")
- print(t2[index2])
- muvelet2()
- elseif XY == "16,6" then
- index2 = index2 + 1
- table.insert(t2, index2, 9)
- m.setBackgroundColour((colours.lightBlue))
- m.setCursorPos(index2,2)
- m.write("9")
- print(t2[index2])
- muvelet2()
- elseif XY == "16,12" then
- print("=")
- m.setBackgroundColour((colours.black))
- m.setCursorPos(18,2)
- m.write("=")
- muv1()
- muv2()
- szamol()
- end
- end
- function muv1()
- for i = 1, #t1 do
- szam = szam + 1
- tabla1 = t1[i]
- print("tabla1: ", tabla1)
- if szam == 1 then num1 = tabla1
- out1 = num1
- print(out1)
- elseif szam == 2 then num2 = tabla1
- out1 = num1..num2
- print(out1)
- elseif szam == 3 then num3 = tabla1
- out1 = num1..num2..num3
- print(out1)
- end
- end
- end
- function muv2()
- for i = 1, #t2 do
- szam2 = szam2 + 1
- tabla2 = t2[i]
- print("tabla2: ", tabla2)
- if szam2 == 1 then number1 = tabla2
- out2 = number1
- print(out1)
- elseif szam2 == 2 then number2 = tabla2
- out2 = number1..number2
- print(out1)
- elseif szam2 == 3 then number3 = tabla2
- out2 = number1..number2..number3
- print(out1)
- end
- end
- end
- function tremove()
- for i = 1, szam do
- szam = szam - 1
- print("szamolas", szam)
- table.remove(t1)
- print(i)
- print("szam: ", szam)
- end
- for j = 1, szam2 do
- szam2 = szam2 - 1
- table.remove(t2)
- print("szam2", szam2)
- print(j)
- end
- if szam == 0 and szam2 == 0 then
- print("teszt")
- index = 0
- index2 = 0
- szam = 0
- szam2 = 0
- num1 = 0
- num2 = 0
- num3 = 0
- number1 = 0
- number2 = 0
- number3 = 0
- end
- end
- function szamol()
- if action == "+" then
- eredmeny = out1 + out2
- m.setBackgroundColour((colours.red))
- m.setCursorPos(1,3)
- m.write(eredmeny)
- print("Eredmeny: ", eredmeny)
- tremove()
- elseif action == "-" then
- eredmeny = out1 - out2
- m.setBackgroundColour((colours.red))
- m.setCursorPos(1,3)
- m.write(eredmeny)
- print("Eredmeny: ", eredmeny)
- tremove()
- elseif action == "*" then
- eredmeny = out1 * out2
- m.setBackgroundColour((colours.red))
- m.setCursorPos(1,3)
- m.write(eredmeny)
- print("Eredmeny: ", eredmeny)
- tremove()
- elseif action == "/" then
- eredmeny = out1 / out2
- m.setBackgroundColour((colours.red))
- m.setCursorPos(1,3)
- m.write(eredmeny)
- print("Eredmeny: ", eredmeny)
- tremove()
- end
- end
- while true do
- kiir2()
- muvelet()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement