Last active
December 25, 2015 04:39
-
-
Save chendo/6918479 to your computer and use it in GitHub Desktop.
A ComputerCraft script that lets you wirelessly request items into an Ender Chest attached to the ME bridge. Requires a MiscPeripheral Chat Box (by default on the left), a ME Bridge (on the bottom), and then you define where players chests are in relation to the ME Bridge. To use, say `give <item id/meta> <amount>`. The script has it capped to 6…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local cb = peripheral.wrap('left') | |
local me = peripheral.wrap('bottom') | |
local chestMapping = {} | |
function getUuid(id,meta) | |
return id + meta * 32768 | |
end | |
chestMapping['_chendo_'] = 0 -- down | |
chestMapping['svgnnblnc'] = 5 -- east | |
chestMapping['DOOMSNAKE'] = 4 -- west | |
while true do | |
event, player, message = os.pullEvent("chat") | |
_, _, item_id_and_meta, amount = string.find(message, "give ([%d:]+) (%d+)") | |
if item_id_and_meta and amount then | |
amount = tonumber(amount) | |
_, _, item_id, meta = string.find(item_id_and_meta, "(%d+):(%d+)") | |
local uuid | |
local direction | |
direction = chestMapping[player] | |
if not direction then | |
cb.tell(player, "No mapping for your chest, contact chendo") | |
else | |
if item_id and meta then | |
uuid = getUuid(item_id, meta) | |
else | |
uuid = tonumber(item_id_and_meta) | |
end | |
if amount > 64 then | |
amount = 64 | |
end | |
print(uuid) | |
retrieved_amount = me.retrieve(uuid, amount, direction) | |
cb.tell(player, "Sent " .. retrieved_amount .. " of " .. item_id_and_meta) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what do you mean with chest mapping how do i use it