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

Turtle --> Monitor display help

Started by Cubstep12, 30 November 2012 - 06:21 AM
Cubstep12 #1
Posted 30 November 2012 - 07:21 AM
I use mining turtles instead of a quarry and was wondering if there was any way to get it to display to a monitor when it is done so i can go start it again
Orwell #2
Posted 30 November 2012 - 08:31 AM
Sure you can, if you let the turtle stop next to a monitor. Are you using excavate for this? If so, try something like this:

local tArgs={...}
local mon
local function findMonitor()
  for i,v in pairs(rs.getSides()) do
	if peripheral.getType(v) == "monitor" then
	  mon = peripheral.wrap(v)
	  return
	end
  end
  error("No monitor found!")
end
shell.run("excavate", unpack(tArgs) )
findMonitor()
mon.write("Done digging!")

Just run it like you'd run excavate.
Cubstep12 #3
Posted 03 December 2012 - 10:13 AM
Sure you can, if you let the turtle stop next to a monitor. Are you using excavate for this? If so, try something like this:

local tArgs={...}
local mon
local function findMonitor()
  for i,v in pairs(rs.getSides()) do
	if peripheral.getType(v) == "monitor" then
	  mon = peripheral.wrap(v)
	  return
	end
  end
  error("No monitor found!")
end
shell.run("excavate", unpack(tArgs) )
findMonitor()
mon.write("Done digging!")

Just run it like you'd run excavate.
so i would just put a monitor next to where the turtle starts and run excavate?
Orwell #4
Posted 03 December 2012 - 10:51 AM
Sure you can, if you let the turtle stop next to a monitor. Are you using excavate for this? If so, try something like this:

local tArgs={...}
local mon
local function findMonitor()
  for i,v in pairs(rs.getSides()) do
	if peripheral.getType(v) == "monitor" then
	  mon = peripheral.wrap(v)
	  return
	end
  end
  error("No monitor found!")
end
shell.run("excavate", unpack(tArgs) )
findMonitor()
mon.write("Done digging!")

Just run it like you'd run excavate.
so i would just put a monitor next to where the turtle starts and run excavate?
Indeed, if the monitor is next to the spot where the turtle finishes (this is the same spot where it starts), the turtle will find the monitor and display "Done digging!" on it.
Cubstep12 #5
Posted 03 December 2012 - 12:51 PM
Sure you can, if you let the turtle stop next to a monitor. Are you using excavate for this? If so, try something like this:

local tArgs={...}
local mon
local function findMonitor()
  for i,v in pairs(rs.getSides()) do
	if peripheral.getType(v) == "monitor" then
	  mon = peripheral.wrap(v)
	  return
	end
  end
  error("No monitor found!")
end
shell.run("excavate", unpack(tArgs) )
findMonitor()
mon.write("Done digging!")

Just run it like you'd run excavate.
so i would just put a monitor next to where the turtle starts and run excavate?
Indeed, if the monitor is next to the spot where the turtle finishes (this is the same spot where it starts), the turtle will find the monitor and display "Done digging!" on it.
i wanted it to display in my house, which is quite far from where the turtle finihes, so maybe having it turn on a redstone signal and hooking up some lights as an indicator wood work, how would i do that?
Orwell #6
Posted 03 December 2012 - 01:06 PM
You could either hook up redstone next to where the turtle starts and put these lines instead of 'mon.write …':

rs.setOutput('left',true)
I'm not sure if you know this, but 'left' is the side of where the redstone is placed. This can be 'left','right','front','back','top' and 'bottom'.

Or else, you could use a wireless turtle and send a signal over rednet to indicate that the turtle is done. A very basic implementation would use this as the last line:

local server_id = 123
rednet.open('right')
rednet.send(server_id, "done_mining")
rednet.close('right')

Then you'd place a computer next to a monitor in your base (within range of rednet, 64 blocks is a safe distance). You run the 'id' command on that computer to get the server_id variable that you need to change in the turtle program. Then on the computer in your base, make a program like this:

rednet.open('top') -- change with the side of the modem

local mon
local function findMonitor()
  for i,v in pairs(rs.getSides()) do
	    if peripheral.getType(v) == "monitor" then
		  mon = peripheral.wrap(v)
		  return
	    end
  end
  error("No monitor found!")
end

findMonitor()
mon.setTextScale(3) -- might want to change this

while true do
  local id,msg,dist = rednet.receive()
  if msg == 'done_digging' then
    mon.write("Done digging!")
    print("Press a key to reset...")
    os.pullEvent('key')
    mon.clear()
    mon.setCursorPos(1,1)
  end
end
Cubstep12 #7
Posted 03 December 2012 - 10:51 PM
You could either hook up redstone next to where the turtle starts and put these lines instead of 'mon.write …':

rs.setOutput('left',true)
I'm not sure if you know this, but 'left' is the side of where the redstone is placed. This can be 'left','right','front','back','top' and 'bottom'.

Or else, you could use a wireless turtle and send a signal over rednet to indicate that the turtle is done. A very basic implementation would use this as the last line:

local server_id = 123
rednet.open('right')
rednet.send(server_id, "done_mining")
rednet.close('right')

Then you'd place a computer next to a monitor in your base (within range of rednet, 64 blocks is a safe distance). You run the 'id' command on that computer to get the server_id variable that you need to change in the turtle program. Then on the computer in your base, make a program like this:

rednet.open('top') -- change with the side of the modem

local mon
local function findMonitor()
  for i,v in pairs(rs.getSides()) do
		if peripheral.getType(v) == "monitor" then
		  mon = peripheral.wrap(v)
		  return
		end
  end
  error("No monitor found!")
end

findMonitor()
mon.setTextScale(3) -- might want to change this

while true do
  local id,msg,dist = rednet.receive()
  if msg == 'done_digging' then
	mon.write("Done digging!")
	print("Press a key to reset...")
	os.pullEvent('key')
	mon.clear()
	mon.setCursorPos(1,1)
  end
end
alright, thanks :D/>