Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function syncSwitches()
- os.execute("cls")
- local ios = getRedstoneAddresses()
- print("Starting to sync. This may take a while.")
- for line in io.lines("addresses.txt") do
- if (pcall(function()
- for chunk in internet.request(apiUrl, {
- key = apiKey,
- token = apiToken,
- action = "sync",
- address = line,
- type = "switch"
- }) do
- end
- end)) then
- print("Synced '" .. line .. "'.")
- else
- print("Failed to sync '" .. line .. "'. It's already there or something's wrong with the web-server.")
- end
- end
- print("Switches synced!")
- os.sleep(2)
- handleUserInput()
- end
- function syncSwitches()
- os.execute("cls")
- local ios = getRedstoneAddresses()
- print("Starting to sync. This may take a while.")
- for line in io.lines("addresses.txt") do
- local success, response = pcall(function()
- return internet.request(apiUrl, {
- key = apiKey,
- token = apiToken,
- action = "sync",
- address = line,
- type = "switch"
- })
- end)
- if success then
- if response then
- print("Synced '" .. line .. "'.")
- -- Process the response if needed
- else
- print("Failed to get a response for '" .. line .. "'.")
- end
- else
- print("Failed to sync '" .. line .. "'. Error: " .. tostring(response))
- end
- end
- print("Switches synced!")
- os.sleep(2)
- handleUserInput()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement