Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getStates(str)
- output = ""
- for i=0, (string.len(str)) do
- cc = string.sub(str, i, i)
- if((cc=='[') or (cc=='"') or (cc==',') or (cc == ']')) then
- i = i+1
- else
- output = output .. cc
- end
- end
- return output
- end
- function lamp()
- response = http.get("http://35.204.206.85/transmit.php?server=35.187.40.176&user=nosk&password=1234&query=Select+*+FROM+Traverskran.Traverskran")
- data = response.readAll()
- response.close()
- status = (string.sub(getStates(data), 1, 1) == '1')
- redstone.setOutput("top", status)
- sleep(1)
- end
- function button(port, state)
- http.get(("http://35.204.206.85/transmit.php?server=35.187.40.176&user=nosk&password=1234&query=UPDATE%20Traverskran.Traverskran%20SET%20Status=" .. boolean(state) .. "%20WHERE%20Utgang=" .. port))
- print("setting " .. port .. " to " .. boolean(state))
- end
- function boolean(stte)
- if(stte) then return "1" else return "0"end
- end
- while true do
- button(0, redstone.getInput("back"))
- lamp()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement