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

Check if something is running

Started by r2range, 14 July 2013 - 12:10 PM
r2range #1
Posted 14 July 2013 - 02:10 PM
am looking for a script that checks if youre quarry is running and it will show on a big screen the quarry is running in a different world

i can use wireless Receiver and Transmitter
albrat #2
Posted 14 July 2013 - 02:59 PM
is this quarry a turtle running a script or an actual Quarry ?

if it is a turtle you could write a little function

function running()
rednet.send(serverid, "running")
end

then every now and then in your code (preferably where you check fuel or make a turn, add running() as a new line in your code)

then on your server message display have it check for rednet.receive() and update if "running" is the message.

Any point on the turtle where it might stop, eg. when it runs out of fuel, add a line stopped()


functtion stopped()
rednet.send(serverid, "stopped")
end

so if you check with "if turtle.getFuel <= 0 then stopped() print("out of Fuel!!") end"
your message server gets the message "stopped" and you can show that the quarry stopped.
r2range #3
Posted 14 July 2013 - 03:30 PM
a real quarry

i want a big monitor and saying something like

[media]http://www.youtube.com/watch?v=BrJWvtvPpaM[/media]

but then saying :

Quarry 1 : Running (9Levels until Bedrock)
Quarry 2 : Stopped ( Crashed)
Quarry 3 : Finished (Reached BedRock)
albrat #4
Posted 14 July 2013 - 04:00 PM
I am swaying towards a turtle and inventory system to manage this… you can make a turtle check an inventory for items, so setup your items from the quarry to come into a chest, then be pumped out of the chest and into a sorting system ( I have my quarries setup like this anyway but using ender chests and pumping pipes.) the turtle could detect when no items are in your receiving chest and report that the quarry has stopped. (not very accurate)

but if you have the quarries I am hoping you have pipes and redpower 2… which means you can use the gates :P/> so place a gate on your pipe from the quarry, set that up to "items traversing" and set it to send a redstone signal if items are traversing, place a computer nearby and have that detect redstone signals and send a message to you display machine telling it that there is activity. (when the quarry stalls the items stop traversing so very quickly you know it stopped).

I currently have nothing that is coded like this… (mostly time displays and login servers / file sharing )
r2range #5
Posted 14 July 2013 - 04:17 PM
I am swaying towards a turtle and inventory system to manage this… you can make a turtle check an inventory for items, so setup your items from the quarry to come into a chest, then be pumped out of the chest and into a sorting system ( I have my quarries setup like this anyway but using ender chests and pumping pipes.) the turtle could detect when no items are in your receiving chest and report that the quarry has stopped. (not very accurate)

but if you have the quarries I am hoping you have pipes and redpower 2… which means you can use the gates :P/> so place a gate on your pipe from the quarry, set that up to "items traversing" and set it to send a redstone signal if items are traversing, place a computer nearby and have that detect redstone signals and send a message to you display machine telling it that there is activity. (when the quarry stalls the items stop traversing so very quickly you know it stopped).

I currently have nothing that is coded like this… (mostly time displays and login servers / file sharing )

ok thats can be done still got the question how to check the lvls it needs to dig until bedrock?
albrat #6
Posted 14 July 2013 - 06:17 PM
I am not sure on checking the lvl's to bedrock. Can you even gather this information from a quarry ?
r2range #7
Posted 15 July 2013 - 01:19 PM
I am not sure on checking the lvl's to bedrock. Can you even gather this information from a quarry ?
idk reason i ask here can some1 please answer or show me a script that does this ?
Sharidan #8
Posted 16 July 2013 - 10:17 AM
I've seen a couple of scripts using a sort of "down is permanently blocked, so I'm there" method for bedrock detection.
Basically what they do, is check the block under the turtle, try to destroy it and then try to move down. If this fails the script assumes that it must be a bedrock block.

Though this method works fine when going straight down, it wouldnt work that well when going horizontally, as gravel will cause roughly the same effect, thus the check has to be performed a number of times, before a roughly correct assumption can be made - i.e. assume no more than say 20 blocks of gravel/sand can fall/drop in front of the turtle and after reaching a count of 21 then assume it could be a bedrock block. Remember that bedrock blocks spawn at different heights and thus need to be checked individually, unless you decide to use positioning to stop and leave the "floor" at say y=6.

Positioning: we do have the GPS api, however I have not yet really worked with it, just read about it. It may be of assistance in helping the turtle figure out at which y level it is.
The quick and dirty way of doing it, is simply to specify at which y level the turtle is, when it starts digging the quarry. Using a counter when decending you could guess the level at which the turtle is at.

If any of this is going to work, your quarry script should by default contain checks that decide whether or not the turtle has in fact moved or was blocked from moving. This kind of check could be adjusted to contain a "I'm blocked" counter, which is then reset every time the turtle actually does move.

My 5 cobblestones worth of contribution here :)/>
apemanzilla #9
Posted 16 July 2013 - 12:58 PM
For detecting the actual level, you could have a turtle dig down on the side of a quarry, and then detect blocks in front of it (the blocks the quarry would clear)
A cave may throw this off, so possibly 4 turtles, one per side and it only reports the layer as "cleared" when they're all detecting open space.
rules54 #10
Posted 16 July 2013 - 01:22 PM
I would have a turtle alongside the quarry like Apemanzilla suggested, however include cobble or any other junk block just to fill the empty spaces in caves/aquifers. It'd be pretty simple; have the turtle dig all the way down to bedrock, filling in holes in front of it to create a solid pillar. Then, come back up the hole while there aren't any blocks in front of it and count how high it went. Every time a block in front of it is broken, it moves down and counts accordingly.
albrat #11
Posted 16 July 2013 - 04:51 PM
I can confirm that the turtle idea works to transmit when your quarry is finished…

Spoiler


--[[ Turtle program dig down counter
--]]
if not turtle then error("Not a turtle") end

-- varibles
local times = 0
local moved = ""
local succeed = true
local depth = 0
local count = 0
local srvid = 5 -- This is your screen output server id.
rednet.open("right") -- Turtle right...
-- functions
function digD()
moved = turtle.digDown()
return moved -- return success or failure.
end
function digF()
moved = turtle.dig()
return moved
end
function moveD()
moved = turtle.down()
return moved
end
function checkItem()
turtle.select(1)
if turtle.getItemSpace(1) > 63 then turtle.select(2) end
end

function placeCob()
checkItem()
turtle.place()
end
function moveU()
moved = turtle.up()
return moved
end
function moveReturn(times)
for i = 1, times do
  placeCob()
  moveU()
  sleep(0.8)
end
end
while succeed do
digF()
digD()
succeed = moveD()
count = count + 1
end
depth = count
print(depth)
moveReturn(count)
rednet.send(srvid, "depth "..tostring(depth-1))
count = 1
block = true
while count ~= depth do
count = count + 1
while block do
  blockdet = turtle.detect()
  sleep(5)
  block = blockdet
end
block = true
moveD()
rednet.send(srvid, tostring(depth - count))
end
rednet.send(srvid, "finished")
moveReturn(depth +3)

-- eof

– Code rushed and un - commented.

I do not feel dumb after writing all that code, watching my turtle go flying down to bedrock… Return to the surface and place blocks all the way up perfectly… Then… no rednet message…
I sat here for almost an hour wondering why the turtle would not send the rednet messages before I realised… (DOH!!) I had not used a wireless turtle. :D/>

To use… place your quarry. Then 1 block to the right Dig down 1 block, (under the barrier that the quarry creates..) place your turtle. Fill slot 1 and 2 with cobblestone. Start program. Wait untill the turtle returns to the surface.

Start your quarry properly, every time the quarry removes the blockinfront of the turtle it moves down after approx 5 seconds, and sends a new depth reading to the "srvid"…

ps. do not forget to give the turtle fuel if you have fuel turned on… (i forgot that too when i placed the new wireless turtle.)

When the turtle moves down it sends the reverse order depth. eg… 67,66,65,64 etc. untill it gets to 0 then the quarry is finished.

edit : for some reason the code and spoiler made all the spacings in my code dis-appear. ( had extra lines to make it clearer).
Edited on 16 July 2013 - 03:22 PM
albrat #12
Posted 16 July 2013 - 06:31 PM
I was thinking about this some more… How do you power your quarries ?
I use a energy link with a gate attached to the golden redstone power pipes to say if power traversing emit redstone signal, which then turns off the energy link untill the power clears the pipe. (this stops my redstone pipes exploding.) but it also gives me a measurement of when my quarry is working. * I know it takes approx 4 to 5 minutes in game ( game minutes ) to clear the pipe so if my redstone circuit is active for over 10 game minutes ( about 8 ticks ) then the quarry is not using the power / aka stopped.

(I can not use the turtle method myself as I am using another world *mystcraft* to mine in… ) I transmit my power via teleport pipes, and retreive the items through an enderchest.


I can make a output screen to show:-
Quarry 1 : running : 34 lvl remaining…
Quarry 2 : running : 50 lvl remaining…
Quarry 3 : Finished.

That is pretty easy… But I would never see a quarry crashed. !!

btw a reboot or exit / save from a world would cause the turtle script above to restart and not work as intended. (unless my return script is better than I hoped). hehe