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

turtle mining drill debug

Started by BHTAelitepwn, 18 September 2013 - 01:42 PM
BHTAelitepwn #1
Posted 18 September 2013 - 03:42 PM
title: turtle mining drill debug

Hello, fellow programmers.

Today, I wanted to make myself a fancy (for my terms :)/>) mining system,
using wireless turtles and ender chests. it was my first ever program using the rednet. API.
the idea is very simple, one controller turtle (melee) sends the rest of the turtles to move one place, dig up and down.
Miner: http://pastebin.com/nqGE9Ha0
Master(melee): http://pastebin.com/N2NieEdt

when i run both of them (yes, i added a variable) the master turtle walks one step (not further) and the mining turtles give the following error:
string:1: attempt to call nil

three last things:
- for the ones recognizing the frameworks of this build: i used direwolf20's mining system as base.
-i dont know how to add the code directly in the forums, so i used links. sorry for that :(/>
-I am always open for improvements:)

have a nice day, and thanks

~BHTA
BigTwisty #2
Posted 18 September 2013 - 04:23 PM
Problem 1: The master is sending a message out that says "checkIn" with a capital I. The correlating function in the slave is "checkin" with a lowercase i. This should cause the loadstring(msg.."(…)") function in the slave to fail when message is "checkIn".

Problem 2: The slave is sending a message called "done". Master is expecting "Done".

Capitalization is something you need to decide on up front and use in all of your projects. This will help reduce errors like this. For instance, event IDs are commonly lowercase separated by underscores, while variable names are camelCase. I would recommend reading up on Lua coding conventions, as this is what experienced coders on the forums will be used to. Help me, help you…
BHTAelitepwn #3
Posted 18 September 2013 - 04:45 PM
thanks a million!!

edit: problem 2, the turtles dont give error messages, but the miner still doesnt move:(
edited script: http://pastebin.com/56jMRbLC (miner)
BigTwisty #4
Posted 18 September 2013 - 04:58 PM
Thinking a bit more, you have a couple of other issues with this code. I assume you intend on making multiple mining turtles. You need to ensure that the "done" message sent by these other turtles do not get translated into commands, as there is no "done" function in the slave code. For that matter any rednet message that happens to be sent from any nearby computer will also cause the slave to crash.

Do you realize that this also opens a massive back door on your slave turtles? A person could have a lot of fun running code on your turtles, and you would have no idea what was happening.

On second thought, forget I said anything… What server do you play on?
BHTAelitepwn #5
Posted 18 September 2013 - 05:02 PM
can someone help me out on how i should change my codes so that mining turtles will move, won't be triggered by any computer,
and most importantly (at this stage): how to make a turtle NOT use the done as a command.

cheers, BHTA
BigTwisty #6
Posted 19 September 2013 - 10:48 AM

if msg == "cycle" then
  cycle()
elseif msg == "checkIn" then
  checkIn()
end

All other messages will now be ignored.