Jump to content


Robert1707's Content

There have been 15 items by Robert1707 (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#223321 button controlled turtle mining

Posted by Robert1707 on 26 June 2015 - 01:25 PM in Ask a Pro

Hi

I am in the proccess of coding a mining program using turtle. At the moment I have finished the mining aspect of the program. Further the turtles that do the mining are controlled by a main computer that (using direwolf20 's button API) displays buttons that can be used to start the mining process. What I have happen is that the user selects a distance they want to mine using 4 different presets. They then select the turtle that is to carry out the mining. What happens is that when the turtle is selected the button turns green indicating that it is mining. I have it set to send the mining instructions wirelessly.

One thing that I have not been able to do is that when the turtle is done mining it should send a signal back to the main computer to toggle the button back to a red state. This would indicate that the turtle has finnished its mining. I have looked into my code and have found out that the reason why it doesn't get the signal is that the os.pullEvent() function waits for an event before moving on to the next line of code. I need to make this pullEvent temporary. Maybe happen for a second then for another second it will wait for an incoming signal from the turtle. I have the following code:

while true do
   getClick()
   id, Report = rednet.receive(1)
   if Report == "done" then
	 if id == 5 then
	   button.toggleButton("Miner1")
	 elseif id == 6 then
	   button.toggleButton("Miner2")
	 elseif id == 7 then
	   button.toggleButton("Miner3")
	 elseif id == 8 then
	   button.toggleButton("Miner4")
	 end
   end
end

For anyone familiar with direwolfs button API the getClick function will be familiar however anyone that isn't what is basically does is wait for a monitor touch. The code above runs the getClick (which is where the problem lies with the os.pullEvent()) and then is should receive a message from the turtle with a string reading "done" it then checks which turtle it came from and toggles the appropriate button back to red. I have worked around this by having another computer that has a display that tells me if the turtle is done mining. getClick code below:


function getClick()
   event,side,x,y = os.pullEvent("monitor_touch")
   button.checkxy(x,y)
end

I was wondering if there is a way in which I can edit the getClick function or the API itself so as the loop from the main code will continue to run. I did find a post ( http://www.computerc...t-with-timeout/ ) that explained how to do it but the coder put the main code into the button API code and ran the program from that rather than use it as an API. I, being new to lua programming and computercraft, don't understand how to incorporate the code of that post into my main code using an API.

Another thing that i would love to do is have it so that buttons on the screen would be used to set the mining value. ie there would be a "+" and "-" button that would be used to set the value. I got this to partly work in tests however I did not know how to display the value on the screen. I got it to display the value however pressing the add and subtract buttons would not refresh the screen and so the value displayed would not update. But I have worked around that by having preset mining values that the miners could run.

Any help would be much appreciated.
Thanks
Robert

My entire code http://pastebin.com/nctbSbcj



#223720 button controlled turtle mining

Posted by Robert1707 on 28 June 2015 - 09:00 PM in Ask a Pro

Thanks a lot for the solution. It will be great to finally get my code to do what i want it to so. Just one question. Where you have used par1, par2, etc could I use any other name just for the sake of remembering what they do.
Thank for the help. I'll finish my code and then I can post it for anyone to use.
Thanks again



#223800 button controlled turtle mining

Posted by Robert1707 on 29 June 2015 - 03:55 PM in Ask a Pro

Thanks a lot. You've been a great help. I just tested the code and it works like a dream. Just putting the finishing touches on it and then I'll post it.



#223927 button controlled turtle mining

Posted by Robert1707 on 30 June 2015 - 10:59 AM in Ask a Pro

Hi

I have another question. I am setting up the system so that the main controller (which is whats coded for above) send a message via lan cable to a "booster computer" so because of the range of wireless modems. I have made it so that the sending of the message is passed on to the correct turtle and it runs it. The only problem is that with the pullEvent function I don't know how to set it up so that the it receives the id of the turtle from a different computer. I'll ellaborate:

rednet.open("right")
rednet.open("left")

while true do
  id, Compid, message = rednet.receive()
  if id == 23 then
    rednet.send(Compid, message)
  else
    rednet.send(23, id, message)
  end
end

above is the code for my booster computer. It is checking whether the id is from the main computer (first part of the if) and if it is it send the message with the id that was sent with it (I edited the main code so that it would not only send a message but the id of the turtle the message is meant for). That part works fine. The next part of the code i think works fine. Basically if the id is not the main computer it has to come from one of my turtles so I have set them up to send the message they need to send with a blank field for the Compid section. The booster computer will thus send the id of the computer that sent the message to it (the turtle) to the main computer.

The problem, however, come in when the message gets to the main computer. The code is checking the id of the computer that is sending the message (I think) which would be the booster in this case. I need it to check the message for the id instead as the booster send the turtle's id in a message.

Let me give an example: I will click on the button to make the turtle mine 50 blocks. I then click on the turtle's button. A message is sent by the main computer to the booster computer (using rednet.send(22, Turtleid, message) the 22 is the booster computer id and the turtleid is set earlier in the code). The booster computer receives the messages using variables (id, Compid, message = rednet.receive()). the booster computer then passes on the message to the turtle (using rednet.send(Compid, message) the Compid is the Receved Turtleid) That part all works fine. When the turtle is done mining it sends a message "done" to the booster (using rednet.send(22, " ", "done")) the blank space is just so that "done" doesn't end up in the Compid field (I used the same receiving variables as before). I think this code also works but I haven't tested it fully. The part i don't know how to edit is the part in the main computer (the code given to me above) as it is waiting for an event not a rednet.receive(). I need it to receive a message from the booster computer containing the id of the turtle that is done mining as well as the message done.

I don't know how well I have explained myself. I hope it is understable.

Again any help will be much appreciated. Thanks



#223945 button controlled turtle mining

Posted by Robert1707 on 30 June 2015 - 01:10 PM in Ask a Pro

Oh. Okay thanks. I'll check it out



#223947 button controlled turtle mining

Posted by Robert1707 on 30 June 2015 - 01:18 PM in Ask a Pro

I attempted to use the repeat program but it didn't work. Is there anything in particular that I need to do. I have made a program that runs it at startup (using shell.run("repeat")) The computer is displaying that it has messages that are being repeated but the turtle is not carrying out any function.



#223949 button controlled turtle mining

Posted by Robert1707 on 30 June 2015 - 02:02 PM in Ask a Pro

yes I have. Below find the code for my turtle and controller:

Pardon the long code blocks. Pastebin keeps removing my pastes.

Mine Controller
os.loadAPI("button")
m = peripheral.wrap("top")
m.clear()

f = false
H = false
T = false
FH = false

M1 = false

Turtleid = 0

function fillTable()
   button.setTable("Miner1", Miner1, 3,13,3,5)
   button.setTable("Miner2", Miner2, 3,13,7,9)
   button.setTable("Miner3", Miner3, 3,13,11,13)
   button.setTable("Miner4", Miner4, 3,13,15,17)
  
   button.setTable("Move", Move1, 15,25,3,17)
   button.setTable("Move Reset", MoveReset, 15,25,19,20)
  
   button.setTable("50", Fifty, 30,38,3,5)
   button.setTable("100", Hundred, 30,38,7,9)
   button.setTable("200", TwoHund, 30,38,11,13)
   button.setTable("500", FiveHund, 30,38,15,17)
   button.setTable("Reset", Reset, 30,38,19,20)
  
   button.screen()
end

function Check()
  if f == true then
	button.toggleButton("50")
	f = false
	rednet.send(Turtleid,"mine50")
  elseif H == true then
	button.toggleButton("100")
	H = false
	rednet.send(Turtleid,"mine100")
  elseif T == true then
	button.toggleButton("200")
	T= false
	rednet.send(Turtleid,"mine200")
  elseif FH == true then
	button.toggleButton("500")
	FH = false
	rednet.send(Turtleid,"mine500")
  end
end

function MoveCheck()
  if M1 == true then
	button.toggleButton("Move")
	M1 = false
	rednet.send(Turtleid, "move")
  end
end  

function Miner1()
   button.toggleButton("Miner1")
   Turtleid = 6
   Check()
   MoveCheck()
end

function Miner2()
  button.toggleButton("Miner2")
  Turtleid = 7
  Check()
  MoveCheck()
end

function Miner3()
  button.toggleButton("Miner3")
  Turtleid = 8
  Check()
  MoveCheck()
end

function Miner4()
  button.toggleButton("Miner4")
  Turtleid = 9
  Check()
  MoveCheck()
end

function Fifty()
   button.toggleButton("50")
   f = true
end

function Hundred()
   button.toggleButton("100")
   H = true
end

function TwoHund()
  button.toggleButton("200")
  T = true
end

function FiveHund()
  button.toggleButton("500")
  FH = true
end

function Reset()
  button.flash("Reset")
  if f == true then
	button.toggleButton("50")
	f = false
  elseif H == true then
	button.toggleButton("100")
	H = false
  elseif T == true then
	button.toggleButton("200")
	T = false
  elseif FH == true then
	button.toggleButton("500")
	FH = false
  end
end

function Move1()
  button.toggleButton("Move")
  M1 = true
end

function MoveReset()
  button.flash("Move Reset")
  if M1 == true then
	button.toggleButton("Move")
	M1 = false
  end
end

rednet.open("left")
fillTable()
button.heading("Miner Controller")

while true do
  local event, Turtleid, par2, par3 = os.pullEvent()

  if event == "rednet_message" and par2 == "done" then
	if Turtleid == 6 then
	  button.toggleButton("Miner1")
	elseif Turtleid == 7 then
	  button.toggleButton("Miner2")
	elseif Turtleid == 8 then
	  button.toggleButton("Miner3")
	elseif Turtleid == 9 then
	  button.toggleButton("Miner4")
	end
  elseif event == "monitor_touch" then
	button.checkxy(par2,par3)
  end
end

turtle
Full = false
NeedTorch = false
CoalNeeded = math.ceil((3000-turtle.getFuelLevel())/80)
UserCount = 0
Torch = 8
NeedFuel = false
MineCount = 0
iCount = 0
iDig = false

function column()
  turtle.digUp()
  turtle.up()
  turtle.digUp()
  turtle.down()
end

function isBlock()
  iDig = turtle.detect()
  while iDig == true do
	turtle.dig()
	iDig = turtle.detect()
  end
end

function Face()
  turtle.dig()
  isBlock()
  turtle.forward()
  column()
  turtle.turnLeft()
  turtle.dig()
  isBlock()
  turtle.forward()
  column()
  turtle.turnLeft()
  turtle.turnLeft()
  isBlock()
  turtle.forward()
  turtle.dig()
  isBlock()
  turtle.forward()
  column()
  turtle.turnLeft()
  turtle.turnLeft()
  isBlock()
  turtle.forward()
  turtle.turnRight()
end

function InventoryFull()
  if turtle.getItemCount(14) >= 1 then
	Full = true
  else
	Full = false
  end
end

function dump()
  for DumpCount = 1,14 do
	turtle.select(DumpCount)
	turtle.drop()
  end
  turtle.select(1)
end

function Needed()
  if Full == true or NeedTorch == true or NeedFuel == true then
	ReturnHome(MineCount)
	turtle.turnLeft()
	dump()
	if NeedTorch == true then
	  turtle.up()
	  turtle.select(16)
	  turtle.suck(turtle.getItemSpace(16))
	  turtle.select(1)
	  if NeedFuel == true then
		turtle.up()
		turtle.select(14)
		turtle.suck(CoalNeeded)
		turtle.refuel()
		turtle.select(1)
		turtle.down()
		turtle.down()
	  else
		turtle.down()
	  end
	end
	turtle.turnLeft()
	ReturnMine(MineCount)
  end
end

function CheckTorch()
  if turtle.getItemCount(16) < 2 then
	NeedTorch = true
  else
	NeedTorch = false
  end
end

function CheckFuel()
  if turtle.getFuelLevel() < UserCount + 100 then
	NeedFuel = true
  else
	NeedFuel = false
  end
end

function Checks()
  CheckFuel()
  CheckTorch()
  InventoryFull()
end

function ReturnHome(blocks)
  turtle.turnLeft()
  turtle.turnLeft()
  for ReturnCount = 1, blocks do
	turtle.forward()
  end
end

function ReturnMine(blocks)
  for ReturnCountM = 1, blocks do
	turtle.forward()
  end
end

function DoneMining()
  turtle.turnLeft()
  turtle.select(16)
  turtle.place()
  turtle.select(1)
  turtle.turnLeft()
  for DoneMiningC = 1, UserCount do
	turtle.forward()
  end
  turtle.turnLeft()
  dump()
  turtle.turnLeft()
  ChangePeriW()
  rednet.send(1,"done")
end

function PlaceTorch()
  turtle.turnLeft()
  turtle.select(16)
  turtle.place()
  turtle.select(1)
  turtle.turnRight()
end

function mine()
  ChangePeri()
  for iCount = 1, UserCount do
	Checks()
	Needed()
	Face()
	MineCount = MineCount + 1
	if Torch >= 8 then
	  PlaceTorch()
	  Torch = 0
	else
	  Torch = Torch + 1
	end
  end
  DoneMining()
end

function Move()
  turtle.turnLeft()
  turtle.turnLeft()
  for MC = 1, 6 do
	turtle.forward()
  end
  rednet.send(1, "done")
end

function ChangePeri()
  turtle.select(15)
  turtle.equipRight()
  peripheral.wrap("Right")
  turtle.select(1)
end

function ChangePeriW()
  ChangePeri()
  rednet.open("right")
end

rednet.open("right")

while true do
  id,message = rednet.receive()
  if id == 1 then
	if message == "mine50" then
	  UserCount = 50
	  mine()
	elseif message == "mine100" then
	  UserCount = 100
	  mine()
	elseif message == "mine200" then
	  UserCount = 200
	  mine()
	elseif message == "mine500" then
	  UserCount = 500
	  mine()
	elseif message == "move" then
	  Move()
	end
  end
end

the booster is just
shell.run('repeat") as a startup program



#224061 button controlled turtle mining

Posted by Robert1707 on 01 July 2015 - 01:51 PM in Ask a Pro

-scratch-

Okay. I figured it all out. The code it running beautifully. Thanks very much for your help. If you wouldn't mind and have some time to spare could you answer another question of mine:
I am now working on a turtle program that would check if the chests used to hold the items for the mining turtle have items in them. I have tried to use the turtle.suck() command in order to check this as I see that it outputs a Boolean value. I tried to use that to set a variable as a Boolean by doing this:
Items = turtle.suck()

I tested it and it didn't work. I was wondering if there is a way that I could get the turtle.suck() command to set a variable as a Boolean flag or if there is another way to check if there are items in the chest.

If all else fails I suppose I could make the turtle suck up an item and it would then check the space in that slot using turtle.getItemSpace(). If that equals 64 then that means that the chest are full.

Thanks again for all the help you have given me Bomb Bloke and thanks to THE_CAT for helping me with the code for the relay even though I didn't need it in the end.



#224809 button controlled turtle mining

Posted by Robert1707 on 07 July 2015 - 09:48 AM in Ask a Pro

Sorry for the late reply. I have been on a trip for a while.

I figured out my issue. What happened is that the turtle was not preforming the suck task each time it ran as it only ran the turtle.suck in the beginning of the program. I edited the program so that each time an if statement was run it would do the turtle.suck (I did this by making the turtle.suck the argument for the if ie IF turtle.suck() == false then ...)

Is there a way of making a programs that will gather info from the user and use it in another program. I am looking to make my code more user friendly by removing the editing portion of the programs (for the ID's and such). What I want to happen is that the User should run a program in which they will enter the ID of the turtles and the main computer. These will then be used in my main code. I don't want to put this in my main code as it means that it would need to be done each time the turtle is sent to mine. (or each time the game starts up). I currently have the ID's hard coded in the code so the user would have to edit the program find the lines that need to be edited and edit them. Quite laborious.

Also I don't know how familiar you are with Direwolf20's Button API but one thing that I don't know how to do is make a blank button. What needs to happen is you need to give you button a name. But it prints the name. I need to toggle different buttons on and off independently of the others so it they have the same name then I don't believe I can do that. I basically need to find a way to have a blank button that just changes colour. I have got around the button naming in the past by numbering buttons ie Miner1, Miner2 etc



#224923 button controlled turtle mining

Posted by Robert1707 on 08 July 2015 - 05:02 PM in Ask a Pro

Hi

Would using the spaces give unique Names? I need to make 8 buttons that are blank but they need to toggle independently.



#225019 button controlled turtle mining

Posted by Robert1707 on 09 July 2015 - 02:23 PM in Ask a Pro

Cool thanks



#225372 button controlled turtle mining

Posted by Robert1707 on 12 July 2015 - 05:45 PM in Ask a Pro

Hi. Sorry to bother again but I need a bit more help. I have added to the turtle code a section that checks if the chests are full and if so sends a signal to the controller computer. The code I believe is working fine except that I get an error: rednet :47: vm error: java.lang.ArrayIndexOutOfBoundsException

This is the code I am using for the checks

function isCoal()
    if turtle.suck(1) == false then
        rednet.send(25, "cFalse")
        isCoal()
    else
        turtle.drop()
        rednet.send(25, "cTrue")
    end
end

I use a similar code to check the torches chest. The idea behind calling the function again is that the turtle will keep checking the chest until the chest gets restocked. This prevents the turtle from continuing the mining until it has the required items to do so. I think that java is giving this error because it thinks that the turtle is caught in an infinite loop.

Could you suggest a course of action or a fix for this.

Thanks



#225481 button controlled turtle mining

Posted by Robert1707 on 13 July 2015 - 11:03 AM in Ask a Pro

Okay thanks. I'll implement it now



#226262 More turtle mining (early and later game mining) +wireless miner

Posted by Robert1707 on 18 July 2015 - 07:03 PM in Turtle Programs

Mine Turtle Instructions


The turtles have been programmed so that they will automatically refuel and gather torches which it places so as to light up the entire tunnel that it mines. it also automatically dumps the items into a chest. The turtle can be operated manually via the manual miner program or with another computer that has buttons that operate the turtles

Mods needed:
  • ComputerCraft
  • Chunky Peripherals (optional but highly recommended)
General Notes:
Any quotes (“) in the instructions should be left out. Only type in what is within the quotes
Parentheses (brackets) that are within the quotes are needed. Don’t leave them out
Everything that is typed in is case sensitive (Caps do matter)
Things encased in square brackets ([ and ]) are things you decide to enter. Don’t type the brackets in eg [name] means enter a name here (enter “Jane” not “[Jane]” without the quotes)

Pastebin Enabled
Make sure that your computer craft is pastebin enabled. Find out by going to your config folder in your minecraft file, find the computer craft config file, open it in wordpad or notepad. Look for this line:
# Enable the "http" API on Computers (see "http_whitelist" for more fine grained control than this)
B:http_enable=true

If your http_enable=false change the false to true. This allows you to download files from pastebin.

Start-up Program
This is a program that will start whenever the computer starts up. Most of the time this will be when you start up your game.
First we need a program named start up so type “edit startup”. This takes you to a blank screen. Type in this screen “shell.run(“[program name]”)” (the quotes in the brakets are important. The program name is obviously the one that you want to run when the computer is started up. Now press Ctrl button on your keyboard use the left and right arrow keys to select the save option and press enter. Do the same but select exit and press enter. Now hold Ctrl + R for about 5 seconds. This reboots the computer.

There is a video explaining the setup. I recommend you watch the video as the written instructions can get a bit confusing. Especially for the Remote Miners code. Check it out on YouTube. Link below:

Video coming soon.





Manual Miner

This is a program that I developed for early game use (as early game as a turtle gets). You just need a turtle and a chunk loader peripheral (little bit hard to craft I know). This is a basic program. If the chest that are needed are not stocked well and often then the turtle may run out of fuel, torches or won’t be able to put the items anywhere. This could lead to the turtle getting lost in the tunnel, the tunnel being dark so mobs spawn, or the turtle will run back and forth from the area its mining to the chest to try and place items. A big waste of Coal.
Instructions:
  • Craft a turtle
  • Turn it into a mining turtle
  • Craft a chunk loader peripheral for Chunky Peripherals (optional but highly recommended)

Posted Image

  • Place down the turtle
  • To the right of the turtle place a chest (can be a double chest)
  • Place a chest on top of the first one and another on top of the second one

Posted Image
  • Place torches in the middle chest and coal in the top chest
  • Open the turtle (right click) and type in “lua” and press enter
  • Put coal in the first slot (as much as you want but it will all be used so be careful)
  • Type in “turtle.refuel()” and press enter (this uses the coal in the first slot to fuel the turtle)
  • Put the Chunk Loader peripheral into the first slot (only if you did step 3)
  • Type in “turtle.equipRight()” and press enter (not “equipright()”!) (only if you did step 3)
  • Type in “exit()” (this closes the Lua interface)
  • Type in “pastebin get kxQTZqZc [program name]” (this downloads the code, program name is what you will type to start the program)
  • To run the program simply type in the name that you called it (The program name for previous step)
  • It will ask you how far you would like to mine
  • Enter a value and walk away (be reasonable. It can do 10000 blocks but if you close the game while the turtle is running it will be stuck where it last mined)
  • It is advisable that you automatically empty the chest that stores items and fill the chest that have coal and torches
  • Before closing the game make sure that all turtles are home so that you won’t lose any. (program stops when game is closed so turtle doesn’t come home)

Remote Miner (Advanced)

WARNING! This setup is complex. The guide is designed to be easy to follow but there are many steps. Basic knowledge on how to use the code editor required. You do not need to know how to code however.
This is intended to be a lot later game. It requires gold and ender pearls as well as quite a lot of other resources. A good items sorting and chest stocking infrastructure is advisable (one such as an AE system). For the mining program you will need:
  • a computer (possibly more than 1, advanced or basic)
  • advanced monitors (12 of them)
  • mining turtles (max 4) (make sure the pickaxe is on the left of the turtle)
  • a wireless modem for each turtle and one for the computer
  • a Chunk Loader peripheral for each turtle
  • chests (at least 3 per turtle)
  • wired modems (or wireless. Discussed later)
  • Networking cable (Not needed for wireless setup)
  • The ID’s of all the computers you will use including turtles (just type id into the computer interface to get the ID)
  • It is advisable that you chunk load the area where your turtles are (I recommend chicken chunks)
Instructions:
  • Craft the items in the above list
  • Turtle setup:
    • Dig a 3 by 3 by 2 deep hole in the wall
    • Place the turtle at the bottom row in the middle of the wall
    • Place a chest to the right of the turtle (single or double)
    • Place a chest above the one just placed and another above that (see diagram in Manual Miner instructions)
    • Leave the bottom chest empty (automatically emptying the chest highly advised)
    • Place torches in the middle chest and coal in the top one
    • Now open up the turtle’s interface
    • Type “lua”
    • Place coal in the highlighted slot in the turtles inventory (don’t need more than one piece but you can put more)
    • Type “turtle.refuel()”
    • Now put a wireless modem in the highlighted slot
    • Type “turtle.equipRight()”
    • Type “exit()”
    • Place a Chunk Loader peripheral in the 15th slot (3rd slot in the last row)
    • Type “pastebin get 9XtwSprN [name]” (no spaces in the name)
    • You can now make a start-up program (see guide above, Program name is the name you gave it in step 15)
    • Repeat for the turtles you have (up to 4 turtles)
  • If you wish to use the Move button (moves the turtle to a mining position behind it)
    • Dig 6 blocks behind the turtle (in 3x3 pattern)
    • Replicate the chest setup from the previous step making sure the chests are on the right if you face the mining wall (back towards the turtle)
  • Computer setup:
    • Place down a computer in the desired location(advised to sink it into the floor)
    • This is your main computer
    • Above the computer place the advanced monitors 3 tall by 4 across
    • On the right hand side of the computer (not the monitors) place either a wireless modem (if close to the turtles) or a wired modem (shift right click)w
    • Open the computers interface (right click)
    • Type “pastebin get HRbMF1Eg button” (important that it is called button)
    • Type “pastebin get ScASCfjj [name]”
    • Type “edit [step 7 program name]”
    • Go to line 17 to 20
    • Replace the Number after the “=” with the ID’s of your turtles (if you don’t have 4 turtles then leave “0” in the place of the ID you don’t have)
    • Save and Close the editor
    • Create a startup program of step 7 program
    • If the computer is far from the Turtles (ie in your house above ground) then place another computer close to where the turtles are
    • This is the Repeater Computer
    • If you do so place a wired modem on this computer (left or right side)
    • Place also a wireless modem on the computer (left or right side)
    • Create a start-up program with the program repeat (shell.run(“repeat”)
    • Above the shell.run line type “rednet.open(“left”)” and on the line above that type “rednet.open(“right”)” (go to beginning of line and press enter to get a line above)
    • Save the program and exit the editor
    • Run networking cable from the wired modem on the main computer to the wired modem on the Repeater Computer
    • Get the ID of your main computer
    • Reboot the two computers (hold Ctrl + R)
  • Go back to your turtles and type “edit [turtle setup step 15 name]”
  • Go to line 11 of the code
  • Change the number after the “=” to the ID of the Main Computer (do this for all turtles)
  • Save and Exit the editor
  • Reboot all turtles (hold Ctrl + R)
  • To use the Controller:
    • For mining click (right click) the distance you would like to mine (Right of the screen) the button turns green
    • Then click the turtle that you would like to do the mining (left of the screen) the distance button turns red and the turtle button turns green
    • When the turtle is done mining the turtles button turns red
    • To move the turtle to the new mining position set up in step 3 click the “move” button then click the turtle that you want to move
    • The turtles button goes back to red when it has completed the move
    • The “C” and “T” button above move indicate is there is torches and coal in the chest Green means there is and red means that you need to refill the chests
    • The turtle will stop mining until the chest are filled and will continue to mine after the chest are refilled (may take so time for turtle to register that the chest are filled 10 seconds at the most)
    • The “reset” button are in case you make a mistake. If you click “50” but wanted to click “100” for instance then just press reset until all distance buttons are red then select the correct distance
    • Same for “move reset”
    • Can’t reset the turtles once they are mining
    • Don’t click the turtle button after it has been sent mining as this will change the colour to red and give a false reading as to the completion of the mining
    • Please don’t exit the game until all turtles have completed their mining. Doing so will result in you having to run down the tunnel looking for the turtle. Picking it up and redoing the whole turtle setup.
    • Should the game crash while the turtles are mining:
      • Then run down the tunnel the turtle made find the turtle
      • Type “label set [name]” this prevents the turtle from losing the programs
      • Pick up the turtle and take it back to the start position
      • Repeat steps 7 to 14 of the turtle setup
That is the end of the instructions. That was long. At least now you have an 4 turtle army to do your mining for you.

About the code:

I have spent over 30 hours developing this program. I did it as a fun, little project to test my skills and also helped me to learn a new programming language (lua). It also helps me with the bane of my time playing minecraft and that is the mining part of it. In the past I have tried to program a turtle to do the mining for me. Never has it succeeded until now. Now I can just leave the turtles to mine while I do other things.

Thanks:

I would like to thank Bomb Bloke and KingOfGamesYami. Both have been a tremendous help with my program and it definitely would not have been completed without their input. Also thanks to direwolf20 whose button API I used.

Conclusion:
Please don’t hesitate to give me suggestions and constructive criticism. Please no hate. Anyone that wants to use my code is welcome. Anyone that wants to edit my code and improve it is welcome with one condition: I would like to be thanked for the writing of the original code.

Please if you like the code recommend it to friends.



#226263 button controlled turtle mining

Posted by Robert1707 on 18 July 2015 - 07:04 PM in Ask a Pro

For anyone interested I have finished my code and posted it. Check it out with the link below:

http://www.computerc...wireless-miner/