Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONFIGURAZIONE
- beneficiario = "eternalcaos"
- importo = 100 -- In IC
- -- Implementazione di dio volevo dire del sensore
- os.loadAPI("ocs/apis/sensor")
- se = sensor.wrap("top")
- -- Configurazione di base del sensore
- side = "left" -- Lato del segnale se viene rilevato un giocatopre
- local maxw, maxh = term.getSize()
- --IMPLEMENTAZIONE DEL DRAWFILLEDBOX
- local function drawPixelInternal(xPos, yPos)
- term.setCursorPos(xPos, yPos)
- term.write(" ")
- end
- local tColourLookup = {}
- for n = 1,16 do
- tColourLookup[string.byte("0123456789abcdef", n, n)] = 2^(n-1)
- end
- function drawFilledBox(startX, startY, endX, endY, nColour)
- if type(startX) ~= "number" or type(startX) ~= "number" or
- type(endX) ~= "number" or type(endY) ~= "number" or
- (nColour ~= nil and type(nColour) ~= "number") then
- error("Expected startX, startY, endX, endY, colour", 2)
- end
- startX = math.floor(startX)
- startY = math.floor(startY)
- endX = math.floor(endX)
- endY = math.floor(endY)
- if nColour then
- term.setBackgroundColor(nColour)
- end
- if startX == endX and startY == endY then
- drawPixelInternal(startX, startY)
- return
- end
- local minX = math.min(startX, endX)
- if minX == startX then
- minY = startY
- maxX = endX
- maxY = endY
- else
- minY = endY
- maxX = startX
- maxY = startY
- end
- for x = minX, maxX do
- for y = minY, maxY do
- drawPixelInternal(x, y)
- end
- end
- end
- function button(x, y, color, text)
- term.setBackgroundColor(colors[color])
- term.setTextColor(colors.white)
- term.setCursorPos(x, y)
- print(text)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- end
- function clear()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function titolo(testo)
- drawFilledBox(1, 1, maxw, 1, colors.blue)
- term.setCursorPos((maxw - #testo) / 2, 1)
- term.setTextColor(colors.white)
- term.write(testo)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- end
- isGoodPayment = false
- isLogged = false
- rs.setOutput(side, true)
- page = 0
- while true do
- if page == 0 and isLogged == false then
- clear()
- titolo("Pagamento con nPay - Accedi!")
- print("\n\n\nNome Utente:")
- utente = read()
- checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. utente).readAll()
- print("\nPassword:")
- password = read("#")
- checkpass = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&richiesta=addebito&valore=0&utente=".. utente).readAll()
- risposta = textutils.unserialize(checkpass)
- tabcheckuser = textutils.unserialize(checkuser)
- if tabcheckuser.stato == "OK" and risposta.stato == "OK" then
- isLogged = true
- page = "logged"
- else
- isLogged = false
- term.setTextColor(colors.red)
- print("\n\nNome Utente o Password errati!\n\nPotrai riprovare tra 2 secondi....")
- sleep(1.5)
- os.reboot()
- end
- elseif page == "logged" and isLogged == true then
- clear()
- titolo("Pagamento con nPay - Benvenuto, " ..utente.."!")
- print("\n\nStai per pagare "..importo.."IC a favore di " ..beneficiario.."!")
- button(15, 10, "green", " PAGA ORA ")
- button(30, 10, "red", " ANNULLA ")
- local event, bt, x, y = os.pullEvent("mouse_click")
- if x > 15 and x < 25 then
- inviaDenaro = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=trasferimento&valore=" .. importo .. "&beneficiario=" .. beneficiario).readAll()
- risultatoInvio = textutils.unserialize(inviaDenaro)
- if risultatoInvio.stato == "OK" then
- -- la variabile che gestisce l'implementazione del sensore viene messa positiva
- isGoodPayment = true
- page = "sensor"
- else
- clear()
- term.setTextColor(colors.red)
- print("\n\nUn errore selvatico e' appena apparso ed il pagamento non e' avvenuto con successo...\nn\Potrai riprovare tra qualche secondo...")
- sleep(3)
- -- Slogghiamo ma in modo bello
- os.reboot()
- end
- elseif x > 30 then
- print("Ok, arrivederci!")
- sleep(1)
- os.reboot()
- end
- elseif page == "sensor" and isGoodPayment == true then
- clear()
- titolo("Pagamento con nPay - Goditelo :D")
- print("\n\nIl pagamento è avvenuto con successo!\Fino a che rimarrai vicino a questo computer potrai usufruire del servizio\nPer sloggarti, allontatati dal computer!")
- -- Implementazione del sensore rileva-player
- -- Il check viene eseguito ogni secondo
- os.loadAPI("ocs/apis/sensor")
- se = sensor.wrap("top")
- ta = se.getTargets()
- for k,v in pairs(ta) do
- if k ~= nil then
- rs.setOutput(side, false)
- else
- rs.setOutput(side, true)
- end
- end
- end
- sleep(0.2)
- end
Add Comment
Please, Sign In to add comment