Guest User

a

a guest
Aug 5th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. rcid = 59  --Remote computer id
  2. c = peripheral.wrap("back")
  3. rednet.open("top")
  4.  
  5. function split(inputstr, sep)
  6.   if sep == nil then sep = "%s" end
  7.   local t={} ; i=1
  8.   for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  9.     t[i] = str
  10.     i = i + 1
  11.   end
  12.   return t
  13. end
  14.  
  15. function moveItem(slotNew)
  16.   c.pullItem("up",1,1,1)
  17.   c.pushItem("up",slotNew,1,1)
  18. end
  19.  
  20. function getBooks()
  21.   message = ""
  22.   for i = 1, c.getInventorySize() do
  23.     if c.getStackInSlot(i) == nil then return message end
  24.     name = c.getStackInSlot(i).destination
  25.     message = message..name.."/"
  26.   end
  27.   return message
  28. end
  29.  
  30.  
  31. while true do
  32.   event, id, message = os.pullEvent("rednet_message")
  33.   n = split(message,"/")
  34.   if n[1] == "name" then
  35.     c.pullItem("up",1,1,1)
  36.     c.condenseItems()
  37.     message = getBooks()
  38.     rednet.send(rcid,message)
  39.   elseif n[1] == "move" then
  40.     moveItem(n[2])
  41.     message = transferred
  42.     --rednet.send(rcid,message)    
  43.   end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment