ocrsdriver
OpenComputers + Refined Storage = ❤️
Allows OpenComputers to access Refined Storage grid nodes via Adapters. This is for Minecraft 1.10.2. Refined Storage for 1.11.2 has this functionality included by default.
Known Issues
- This is currently unrestricted, i.e. you can export items and fluids using just a cable - and fast.
Available Commands
Method | Description |
---|---|
isConnected() | Returns whether the grid node is connected to a network |
getEnergyUsage() | Returns the energy usage of the whole network in RS/tick |
getItems() | Returns a list of all itemstacks stored in the network |
getItem(itemstack, cmpMeta, cmpNbt, cmpOre) | Returns a stack in the network matching the given itemstack |
extractItem(itemstack, amount, side) | Extracts the given amount of itemstack to the specified side and returns the number of transfered items. |
getFluids() | Returns a list of all fluid stacks stored in the network |
getFluid(fluidstack) | Returns a stack in the network matching the given fluidstack |
extractFluid(fluidstack, amount, side) | Extracts the given amount of fluid to the specified side and returns the amount of millibuckets transfered. |
getTasks() | Returns a list of crafting tasks the system has currently queued |
getPatterns() | Returns a list of all crafting patterns in the network |
hasPattern(itemstack) | Returns true if the system has a pattern for the given itemstack |
getMissingItems(itemstack, amount) | Returns a list of all items missing to craft the given itemstack in the given amount |
craftItem(itemstack, amount) | Requests crafting of the specified item in the specified quantity |
cancelCrafting(itemstack) | Cancels all crafting operations for the given itemstack and returns the number of cancelled tasks |
Examples
Drop all items you got more than 8192 of
Place a Trash Can below an interface connected to an OpenComputers Adapter.
local component = require("component") local sides = require("sides") local rs = component.block_refinedstorage_interface local limit = 8192 local side = sides.down for i,stack in ipairs(rs.getItems()) do while(stack.size > limit) do local dropped = rs.extractItem(stack, stack.size - limit, side) stack.size = stack.size - dropped if(dropped < 1) then break end end end
Keep 64 torches and levers in your crafting system
Don't forget to teach a crafter the recipe for torches and levers
local component = require("component") local sides = require("sides") local rs = component.block_refinedstorage_interface local targetAmount = 64 local items = { {name = "minecraft:torch"}, {name = "minecraft:lever"} } while(true) do for i,stack in ipairs(items) do if(rs.hasPattern(stack)) then local rsStack = rs.getItem(stack) local toCraft = targetAmount; if(rsStack ~= nil) then toCraft = toCraft - rsStack.size end if(toCraft > 0) then rs.craftItem(stack, toCraft) end else print("Missing pattern for: " .. stack.name) end end os.sleep(5) end
update it to 1.12.2?
In reply to apatel13:
I'm stumped on how to get my program to not crash when it gets an "incorrect" itemstack. Here's an example:
But it will crash if given "minecraft:blah" for example, when I'd rather just catch an error and move on (this is parsing input from a chatbox).
Love the mod, but I can't seem to get the item retrieval or crafting working for botania's mystical petals (only thing I've tried really). Code and result shown below. Even if the retrieval did work, I can't fathom how the crafting would considering there are no parameters available to it to indicate that it should check metadata and indeed, if i try crafting the gray petals, it just crafts the white ones. Code and results below: (the gray petal table is a copy paste from the results of getItems() and it seems the 'damage' member is the distinguishing feature among the different petals.)
Code:
Output:
Currently this mod requires both the client and the server to have this mod installed. Is this necessary? I want to add this to FTB beyond server without requiring everyone to do so.
In reply to LightningShock:
in @Mod annotation as I've seen here. I got your source, tried it and it worked!
In reply to LightningShock:
In reply to SiamoTitan:
I have a script, similar to your 8192 items example, that extracts all items with (damage / maxDamage) > 0.7. It works fine for normal items, but it fails on enchanted items with this message:
Could this be caused by your driver or is it probably a bug in Refined Storage or OpenComputers?
In reply to edmccard:
In reply to Davenonymous:
Oh well. It would be cool if any stack returned by getItems could be passed to extractItem. Either way, thanks for your work on this mod!
Thanks you for your work, this is a really great mod to use with sky fatory 3.
Is there any way to craft items with a damage tag (andesite or diorite for example)? There is a recipe available but I am not able to filter for it.
While listing all items via getItems, the damage-value can be retrieved but I can't figure out how to pass them for hasPattern or craftItem.
I tried the following:
{name="minecraft:stone:5"}
{name="minecraft:stone", damage=5}
{name="minecraft:stone", tag="Damage:5"}
The last one supposedly does filter somehow, but the return is always nil "Not in GZIP format".
In reply to Forge_User_03065490:
In reply to Davenonymous:
Oh, I guess that would be helpful.
If I go through the list of items (via getItems) and filter for name "minecraft:stone" and damage 5, I get the one with Label "Andesite". And I figured that this one could be used to check for pattern and craftItem and it works. So currently I am using a list search to get the correct item stack size.
For getItem, the filter doesn't work:
getItem({name="minecraft:stone:5"}) returns "invalid item stack".
getItem({name="minecraft:stone", damage=5}) returns Label "stone" as does getItem({name="minecraft:stone"}). So the Filter isn't passed through.
getItem({name="minecraft:stone", tag="Damage:5"}) gives the specified nil with comment "Not in GZIP format".
Even if I put in the item I got from filtering the list of getItems (which is clearly Andesite), I get the one with Label "stone".
In reply to Forge_User_03065490:
That sounds like a bug, I'll look into it.Take another look at the getItem signature: getItem(itemstack, cmpMeta, cmpNbt, cmpOre)In reply to Davenonymous:
Oh wow, I figured it was something simple but I didn't think it was this easy. Thanks a lot!
Could you update for 1.11.2, please?
Any plans on continuing development on this? I'd love a good driver for this that would allow you to request crafting jobs. That would be huge! Think of all the things you can do with that.
In reply to teamenternode:
Have fun! And I would love to see what things you do with it!
In reply to Davenonymous: