Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pim = peripheral.wrap("pim_1")
- local mon = peripheral.wrap("monitor_71")
- --Don't change anything below this line
- if (not fs.exists("invjson")) then
- shell.run("pastebin", "get", "4nRg9CHU", "invjson")
- end
- os.loadAPI("invjson")
- local lastPlayer
- function renderBottom(_color)
- mon.setBackgroundColor(_color)
- _x, _y = mon.getSize()
- for x = 1, _x, 1 do
- mon.setCursorPos(x, _y)
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.black)
- end
- function playerOn()
- event, lastPlayer, side = os.pullEvent("player_on")
- end
- function playerOff()
- event, side = os.pullEvent("player_off")
- lastPlayer = nil
- end
- function paste()
- pasteObject = {}
- pasteObject.player = lastPlayer
- pasteObject.items = {}
- for i = 1, pim.getInventorySize(), 1 do
- pasteObject.items[""..i] = pim.getStackInSlot(i)
- if (i % 2 == 1) then
- renderBottom(colors.cyan)
- else
- renderBottom(colors.blue)
- end
- end
- --print(invjson.encode(pasteObject.items[""..1]))
- --print(invjson.encode(pasteObject))
- sName = "invpaste"
- sText = invjson.encode(pasteObject)
- key = "0ec2eb25b6166c0c27a394ae118ad829"
- response, arg0, arg1 = http.post(
- "https://pastebin.com/api/api_post.php",
- "api_option=paste&"..
- "api_dev_key="..key.."&"..
- "api_paste_format=lua&"..
- "api_paste_name="..textutils.urlEncode(sName).."&"..
- "api_paste_code="..textutils.urlEncode(sText)
- )
- if response then
- print("Success")
- sResponse = response.readAll()
- response.close()
- sCode = string.match(sResponse, "[^/]+$")
- print(sCode)
- mon.setCursorPos(1,1)
- mon.write(sCode)
- renderBottom(colors.lime)
- else
- printError("Failed")
- mon.setCursorPos(1,1)
- mon.write("Upload failed")
- renderBottom(colors.red)
- end
- end
- mon.setTextScale(2)
- mon.clear()
- renderBottom(colors.red)
- while (true) do
- if (parallel.waitForAny(playerOn, playerOff) == 1) then
- mon.clear()
- renderBottom(colors.cyan)
- if (parallel.waitForAny(playerOff, paste) == 1) then
- mon.setCursorPos(1,1)
- mon.write("Don't step off")
- renderBottom(colors.red)
- end
- else
- renderBottom(colors.red)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement