Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --2013 Ichabod_Clay (Ichabod2032)
- --Item charger script for Minecraft.
- --This script uses an Interactive Sorter to take an item (ideally from an ender chest)
- -- and send it off to charge in a charging station (batbox, MFE, MFSU).
- --The way I have it set up is the Sorter scans the chest every so often and, if the
- -- proper item is found, takes the item and sends it to a charge station through a
- -- Buildcraft pipe.
- --The return trip is handled by an Autarchic AND Gate that is set to extract the item
- -- from the charge station once it is full. Set 1 setting to energy pulse when an item is
- -- in inventory, and the other setting set to energy pulse when charging a fully charged
- -- item. Easy Peasy!
- tArgs = {...};
- if #tArgs ~= 1 then
- print("Usage: <name of program> <side sorter is attached to>");
- return;
- end
- local sorter = peripheral.wrap(tArgs[1]);
- --This is the ID of the Advanced Jetpack.
- --Theoretically, you could change it to whatever you need to have charged.
- local jetpackID = 30481;
- --03/26/13
- --Found that wiki page was incorrect on east and west values. Switched them.
- --Tested on SSP and SMP worlds with CraftOS 1.5, unsure of the
- -- interactive sorter's mod version.
- local direction =
- {
- down = 0,
- up = 1,
- north = 2,
- south = 3,
- west = 4,
- east = 5
- }
- --Helper function to find the actual item ID and
- -- meta value from a UUID.
- local function getID(uuid)
- id = 0;
- meta = 0;
- if uuid > 32768 then
- id = uuid % 32768;
- meta = (uuid - id) / 32768;
- else
- id = uuid;
- meta = 0;
- end
- return id, meta;
- end
- --Simple helper function. Returns true and uuid of item if found,
- -- false otherwise.
- local function findJetpack(direction)
- local inventory = sorter.list(direction);
- for uuid, count in pairs(inventory) do
- local id, meta = getID(uuid);
- if (id == jetpackID) and (meta ~= 1) then
- return true, uuid;
- end
- end
- return false;
- end
- --Make sure to fill in the required parameters before using!
- --The sorter's 'extract' function has the following parameters:
- -- sorter.extract(from, uuid, to, amount)
- --Find the 'from' and 'to' direction values from the table provided
- -- at the beginning of this script.
- --Main loop start! WOO!
- while true do
- local jetpackFound, uuid = findJetpack("Fill Me In!");
- if jetpackFound then
- sorter.extract("Fill me in!", uuid, "Fill me in!", 1);
- print("Day: "..os.day().." Time: "..os.time());
- print("Item sent to charge");
- end
- sleep(10);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement