Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local sides = require("sides")
- local serialization = require("serialization")
- itemTable = {}
- receivingModemAddress = "baf9bf02-7b0e-4b67-879e-8a6a6b71ff8a"
- function checkCurrentChest()
- slot = 1
- while component.inventory_controller.getStackInSlot(sides.down, slot) ~= nil and slot < component.inventory_controller.getInventorySize(sides.down) do
- itemInfo = component.inventory_controller.getStackInSlot(sides.down, slot)
- myTable = {}
- myTable[itemInfo.label] = itemInfo.size
- for x,y in pairs(myTable) do print(x,y) end
- sendItemDataToComputer(serialization.serialize(myTable))
- slot = slot + 1
- end
- end
- function addToTable(itemName, itemAmount) -- Adds an item/amount to the current item table.
- if itemTable[itemName] == nil then
- itemTable[itemName] = itemAmount
- else
- itemTable[itemName] = itemTable[itemName] + itemAmount
- end
- end
- function sendItemDataToComputer(itemLabel)
- component.modem.send(receivingModemAddress, 888, itemLabel)
- end
- function pairsByKeys (t, f) -- Sorts a table into alphabetical order.
- local a = {}
- for n in pairs(t) do table.insert(a, n) end
- table.sort(a, f)
- local i = 0 -- iterator variable
- local iter = function () -- iterator function
- i = i + 1
- if a[i] == nil then return nil
- else return a[i], t[a[i]]
- end
- end
- return iter
- end
- function firstToUpper(str) -- Changes the first letter of the input string to uppercase.
- return (str:gsub("^%l", string.upper))
- end
- checkCurrentChest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement