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

computers and quarries

Started by thetrin777, 15 January 2015 - 09:45 PM
thetrin777 #1
Posted 15 January 2015 - 10:45 PM
Hello all!

So i've started a new project. And since my monitor program worked so well thanks to all you gurus, I figured I would post it back on here.

the only thing is, I have a whole lot of questions and I don't know if I should ask them all at once or individually.

What im doing is running two quarries at once. Each has a combustion engine. The water is supplied from an ocean via 2 stirling engines running a pump that pipes it to the combustion engines, one pump per engine. The same thing goes for the fuel, except its from 2 tanks being pulled out by stirling engines connected to the wooden fluid pipe on top. So six engines all total, and they all connect to the computer via rednet cables.

Ill go ahead and ask one, but if someone could tell me if i should ask all or not would be great. I dont wanna spam the forums up.

That being said, heres the first. Can the quarry machine itself be monitored or return a signal telling the computer it has stopped and cut the engines? Cause once the quarry finishes theres no reason to keep the engines on.

Lemme know, and thanks a million in advance! :)/>
Quintuple Agent #2
Posted 15 January 2015 - 11:10 PM
Well, If whatever mod pack you are using has OpenPeripheral then you can use .isActive(), it will return false when the quarry is done.
It would be something along the lines of

rs.setOutput("side",true) --replace 'side' with which side you have redstone on
local quarry=peripheral.wrap("side") -- replace 'side' with whatever side the quarry is on
--Loop until the quarry is done
while quarry.isActive() do
sleep(1)
end

--ture off redstone signal that goes to the engines
rs.setOutput("side",false)

switch the true and false on the rs.setOutput if you want the redstone to start out off and then turn on


However, if you do not have OpenPeripheral, I am not sure if there is a way. I will try to check but so far I have found nothing.

Edit: .isActive() works for Buildcraft quarries, I don't know if it would work of any other type.
Edited on 15 January 2015 - 10:14 PM
KingofGamesYami #3
Posted 15 January 2015 - 11:11 PM
I'm going to assume you mean BC or TE quarries. You might be able to use it as a peripheral via openP, but I don't know for sure.

To test this, enter this in the lua prompt.


peripheral.getType( "side" )

If this gives you a result, you can use it. If not, you cannot.

Edit: Ninja'd
Edited on 15 January 2015 - 10:11 PM
thetrin777 #4
Posted 16 January 2015 - 02:39 PM
Guess i should have mentioned im on tekkit, using buildcraft, and it does have openperipheral. Tested the quarry and i can wrap it.
Awesome.

Next question. Can/should i define seperate functions to check each of the individual stirling engines on the water pumps and see if they have stopped, and if so, it cuts power to the combustion engines to prevent an explosion?
KingofGamesYami #5
Posted 16 January 2015 - 03:15 PM
You can, but you are better off with a for loop. That way you don't have to write the same code several times.


local ce = {}
for _, name in ipairs( peripheral.getNames() ) do
  if peripheral.getType( name ) == "combustion_engine" then --#note: I'm not sure what the actual type is
    ce[ #ce + 1 ] = peripheral.wrap( name )
  end
end

function check()
  for k, v in pairs( ce ) do
    --#check if they have stopped
  end
end
thetrin777 #6
Posted 16 January 2015 - 04:12 PM
Do the engines need to be connected to a wired modem to send signals back to the computer, or will the rednet cables that are already there work?
KingofGamesYami #7
Posted 16 January 2015 - 04:32 PM
I believe you need a wired modem for peripherals. If you were communicating with another computer, you could use rednet cables.
thetrin777 #8
Posted 16 January 2015 - 05:15 PM
Ok, thanks. In that case im gonna have to re-structure this build cause i dont have enough room to add anything else to it.. oh well. Ya live and learn right? I am gonna save that for loop for when i rebuild though.