Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getCard()
- print("Aspirazione carta")
- rs.setOutput("left", true)
- sleep(0.5)
- rs.setOutput("left", false)
- sleep(1)
- end
- function unloadCard()
- print("Scaricamento carta")
- rs.setOutput("back", true)
- sleep(0.5)
- rs.setOutput("back", false)
- sleep(1)
- end
- function oustCard()
- print("Carta scartata")
- rs.setOutput("right", true)
- sleep(0.5)
- rs.setOutput("right", false)
- sleep(1)
- end
- function reloadCards()
- print("Ricarico carte")
- rs.setOutput("bottom", true)
- for i=60,1,-1 do
- print("Attesa: " .. i)
- sleep(1)
- end
- rs.setOutput("bottom", false)
- end
- sensor = peripheral.wrap("top")
- print("Avviato")
- while true do
- getCard()
- print("Lettura carta")
- a,b,c,d = sensor.get(1)
- if (type(b) == "string" and b == "OK") then
- name, contract, id = string.match(c, "(.*),(.*),(.*)")
- if (type(name) == "string" and type(contract) == "string" and type(id) == "string") then
- print("Nome: ".. name)
- print("Contratto: " .. contract .. " kW")
- print(b)
- print("Consumo: " .. tostring(textutils.serialize(d.energy)) .. "Wh")
- print("Contatore: " .. id .. " ")
- print("...................")
- rest = http.get("http://luanet.rgbcraft.com/servlets/ergb/aggregatore.php?utente=" .. name .. "&contatore=" .. contract .. "," .. id .. "&lettura=" ..d.energy).readAll()
- print(rest)
- unloadCard()
- else
- oustCard()
- end
- else
- print("val b era uguale a ")
- print(b)
- oustCard()
- end
- if (rs.getInput("front") == true) then
- reloadCards()
- end
- sleep(2)
- end
Add Comment
Please, Sign In to add comment