Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function set(channel, data)
- -- Function originally coded by ilgazzi
- data = tostring(data)
- url = "http://craft-a-cloud.mooo.com/upload.php?name="..channel.."&data="..data
- encoded=textutils.urlEncode(url)
- http.request(url)
- local i=0
- while get(channel) ~= data do
- if i >= 20 then
- return false
- end
- sleep(0.25)
- i = i+1
- end
- return true
- end
- function get(channel)
- -- Function originally coded by ilgazzi
- url = "http://craft-a-cloud.mooo.com/download.php?name="..channel
- encoded=textutils.urlEncode(url)
- response = ""
- while response == "" do
- http.request(url)
- event, returnurl, response = os.pullEvent("http_success")
- response = response.readAll()
- end
- return response
- end
- while true do
- print("Orders:")
- command = io.read()
- if command == "help" then
- print("store <item> <qty>")
- print("get <item> <qty>")
- print("charge <item>")
- else
- set("action", command)
- while true do
- sleep(0.5)
- answer = get("return")
- if answer == "nil" then
- sleep(1)
- else
- print(tostring(answer))
- set("return", "nil")
- break
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement