This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
McBainStraddi's profile picture

How to get inventory items.

Started by McBainStraddi, 11 May 2015 - 11:53 AM
McBainStraddi #1
Posted 11 May 2015 - 01:53 PM
Monster 1.1.2
ComputerCraft
ReactorCraft

Hi,

I suppose this question was already asked, but I pass this weekend seeking the internet for an answer wthout finding anything.

Infact, I need to know when an inventory of a device is empty and to do that, I want to use ComputerCaft.

Let's consider a "chest". ( a pebble bed reactor core in fact )

I want to create a program that, when the inventory of the chest is empty, the program must send a redstone impulse.

But I don't know where to begin.


===
The Final goal is to monitor temp° and the inventory of the pebble bed reactor core, when it works. Once the inventory is empty, the program must impulse the redstone to give the order of sending another item (TRISO). And activate emergency cooling system in case of overheat.

Here an exemple of the kind of program I want to use:

core = peripheral.wrap ('back')

while true do
	
if core.getTemperature() < 1500 then		
redstone.setOutput('left', true)
	
else
redstone.setOutput('left', false)
	
end

os.sleep (1)
end

Thank you for your help.

Have a good day.
Lignum #2
Posted 11 May 2015 - 03:03 PM
Let's consider a "chest". ( a pebble bed reactor core in fact )

I want to create a program that, when the inventory of the chest is empty, the program must send a redstone impulse.

But I don't know where to begin.

One way to do it is to use a redstone comparator. If the comparator outputs no redstone signal, the chest is empty. This, of course, assumes that your "chest" supports the comparator.
McBainStraddi #3
Posted 11 May 2015 - 04:18 PM
There is not enough space for this system.

Moreover, it seems to not work with my devices.

Thank you for helping =)
Cranium #4
Posted 11 May 2015 - 05:07 PM
If you install openperipherals, you can wrap almost anything as a peripheral, and get information about it.
McBainStraddi #5
Posted 11 May 2015 - 06:10 PM
That's interesting. But in facts, my main issue is that I can't find the said information.

I don't know how to find the instructions of computerCraft

ex : chest.getInventory(all)

I found some, but not what I want and not … officially (like a wiki)

what I'm looking for, is the list of instrucitons accepted by computerCraft, that I may use.
Lyqyd #6
Posted 11 May 2015 - 07:45 PM
The grand majority of stuff that ComputerCraft provides is documented on the wiki. Other mods add further functionality (like OpenPeripheral adding the ability to use chests as peripherals), so you must also use their documentation to find out what they can do. OpenP in particular only provides documentation in-game. There is no wiki or other documentation for that mod.
Kaikaku #7
Posted 11 May 2015 - 09:01 PM

I want to create a program that, when the inventory of the chest is empty, the program must send a redstone impulse.

But I don't know where to begin.

When you don't want to install further mods you can check for items in a chest relativley easy with a turtle.
The turtle is able to suck items from inventories into its own inventory and drop it back.

All (most?) of the turtle commands return true/false if successful/or not, so you could start with some thing like this:

if turtle.suck() then
  -- turtle successfully sucked in s.th.
else
  -- nothing could be sucked in
end

Probably you need to put back the sucked in item.
I don't know the pebble bed reactor core, but maybe you would also need to check wether doing the above every 1sec is a good idea.
McBainStraddi #8
Posted 12 May 2015 - 11:18 PM
Hum, thanks guys, I'll investigate these ideas.

I keep you in touch.