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

Trying to automate with openccsensors

Started by ihatetn931, 28 February 2013 - 02:46 PM
ihatetn931 #1
Posted 28 February 2013 - 03:46 PM
Nice, I can finally post a topic.

Now I would post in the openccsensors topic but this has to do more with coding then OpenccSensors.

I am new to lua(know pawno tho), just started learning yesterday and so far I think I've done ok. It has gotten me addicted to minecraft (again), great job on the mod(s). ok now on topic.

What I need help with is, say I have a chest with 54 slots in it and all those slots but 1 is filled with cobblestone and the single slot is filled with smoothstone, how would I go about making it so it only pulls the smoothstone out of that one slot (slot won't be the first slot) and send a redstone pulse and the redstone pulse will stay on intill the slot gets filled with the correct item basically it would pulse a filter(rp2) one time so it pulls it out possibly making uraium cell and isotopes run through the same pipe.

Trying to automate my breeder reactor so, it pulls out the uranium cells. I have no problem putting isotopes in and pulling them out. I can do the redstone part but getting the info I can't do just yet.

I'm sure there is prolly an easy way to do it with a turtle or something but I haven't really gotten in to the turtles yet, still trying to learn lua.
KaoS #2
Posted 01 March 2013 - 07:28 AM
you cannot select the slot you want to take an item from. I would recommend you use an RP2 filter or you have to pull out every item until you get to the right one and then re-insert all of the items
ihatetn931 #3
Posted 01 March 2013 - 07:44 AM
I think I kinda found a way to do it, it's prolly not the best way tho.


function Check() --ran in a while loop
	local currentStackSize = 0; --sets stack size to 0
	local details = sensor.call("right", getdetails , "-6,2,0") --get info from sensor
	local firstSlot = details.Slots[41]; --i put a slot number here for the item i wanna check
	currentStackSize = tonumber(firstSlot["Size"]) --gets the amount in the slot
	if firstSlot.Name ~= "Heat-Capacity Reactor Plating"  then --basically picks if the correct item is in the slot (slots will have to be set manually) if not then it will pulse the output 
	--was thinking about also checking to see if the size in the slot is correct
		BundleOn(colors.white, 'left') --turns the bundlecabl on
		sleep(0.5) --waits 
		BundleOff(colors.white,"left") --turns bundle cable on
		end
end	

Bad thing about this is there will be a lot of if statements.

Basically it will trigger the wire if the correct item isn't in the slot. Only need to do it with certain slots cause reactor heat plating will prolly be in the rest or something else. The only way the slots (that I set) are filled by a computer. Hope that makes sense