6 posts
Posted 15 August 2013 - 04:14 AM
i want my mining turtle to place a block when it receive a redstone signal. and destroy that block when i get the redstone signal off. because i don't want always the whole applied energestic network to connect. so 1 cable need to be mined and placed when i wanted too.
8543 posts
Posted 15 August 2013 - 02:57 PM
Split into new topic.
Why not just use one of the AE dark cables, which break the network at that cable when they receive a redstone signal? I mean, you could use a quick script to do it, but using the dark cables seems much easier in this case.
6 posts
Posted 16 August 2013 - 01:53 AM
thx for your answer. didn't know that cable exist. but turtles are still cooler:P how can i close the topic? or am i not able to do that?
199 posts
Location
Switzerland
Posted 16 August 2013 - 02:35 AM
hi thijs,
not tested but sth like this should work.
local status = true
while true do
mysignal = redstone.getInput("back") --checks redstone signal at the back
if mysignal == true and status == true then --if signal true and status true digs the cable (status true is just to make sure he is not digging whole time)
turtle.dig() --dig the cable in front
status = false --set status to false means network is off
elseif mysignal == false and status == false then -- if no redstone signal and network is off
turtle.select(1) -- select slot with the cable
turtle.place() --place the cable
status = true --remember that system is on now.
end -- end if
sleep(1) --sleep 1 second
end --end while
Edited on 16 August 2013 - 12:55 AM
7508 posts
Location
Australia
Posted 16 August 2013 - 02:45 AM
not tested but sth like this should work.
local status == true
Nope :P/>
A slightly improved version of the above (better for servers as the computer doesn't run every second, and only when it is needed … also no bug ;)/> )
local status = true
turtle.select(1)
while true do
os.pullEvent("redstone") --# wait until there is a change in redstone! Instead of sleeping
rsSignal = rs.getInput("back")
if rsSignal and status then
turtle.dig()
status = false
elseif not (rsSignal and status) then
turtle.place()
status = true
end
end
Another way I'd do it…
turtle.select(1)
while true do
os.pullEvent("redstone")
local rsInput = rs.getInput("back")
if rsInput and turtle.detect() then
turtle.dig()
elseif not (rsInput and turtle.detect()) then
turtle.place()
end
end
199 posts
Location
Switzerland
Posted 16 August 2013 - 03:01 AM
corrected my mistake,
and yes, waiting for redstone event is much better cause then you don't need the state part.
i always forget that os.pullEvent for redstone thing
thanks bit you are the master :D/>