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

[Lua]Miner Stops at Identified

Started by Will11690, 09 April 2018 - 11:46 PM
Will11690 #1
Posted 10 April 2018 - 01:46 AM
To start off with I'm playing Minecraft version 1.7.10. I'm working on making a mining program that will tell turtles to place down a Mining Well, Fluxduct, Ender Chest, Chunk Loaders, and a Tesseract. Currently i'm stuck.

The program is supposed it Identify the turtles, tell them to check their fuel, then tell them to mine. When I run the main program the system hangs after Identified and the main computer won't receive the next message to start the next part(It's not printing out the identified turtle names so I believe this is where the hang is). I'm wondering if anybody is able to help me out.

If you need more details then let me know,

This is the code I have so far

MinerControl:
https://pastebin.com/28R71nV4

Miner1:
https://pastebin.com/jz68KvD4

Tesseract:
https://pastebin.com/hqMiEnaY

Chunkloader1:
https://pastebin.com/RpQ6nCmh

Chunkloader2:
https://pastebin.com/pVi6ppd3
KingofGamesYami #2
Posted 10 April 2018 - 02:26 AM
Why are you overwriting various values in your trustedIDs table when you receive a rednet message from a random computer? Also, your code won't work unless the other computers respond in the correct order, which is not guaranteed.
Will11690 #3
Posted 10 April 2018 - 03:17 AM
I'm just starting to learn coding and lua is new to me, what do you mean by overwriting values in the table?

What would be a better way to do it so the correct order thing isn't an issue? I've been working on this for 2 days now and am so confused.
KingofGamesYami #4
Posted 10 April 2018 - 04:03 AM
Lets take line 15 for example:


trustedIDs[17], message = rednet.receive()

This sets trustedIDs[17] to the ID of whatever computer sent the message you just received. Originally, this value was 25. After this line executes, the value could be 3. Or maybe it's 5. Who knows?

I recommend getting a very small part of your overall program working before writing anything this large. For example, write a "ping" program and a responder for it.

In general, programs are developed in pieces, then assembled. This is helpful because you can more easily identify which bit of code isn't behaving properly.
Will11690 #5
Posted 10 April 2018 - 01:16 PM
Ohh okay, thanks for the tip.

When I get back home from work I'll start rewriting it.

Also I've been using g Notepad ++ to make the code then copy pasting it into the computer program file because it's way easier than typing it into the computer, is there an issue with me doing that? I haven't noticed any problems so far
Edited on 10 April 2018 - 11:20 AM
KingofGamesYami #6
Posted 10 April 2018 - 02:19 PM
Nope. I edit my files directly using sublime text 3 (no copy/paste step, just saving). If you want to try that, I recommend the LuaExtended package.
Purple #7
Posted 10 April 2018 - 02:58 PM
Just make sure to engage Lua formatting in notepad++.
Lupus590 #8
Posted 10 April 2018 - 07:41 PM
I think you may find this helpful: http://www.computercraft.info/forums2/index.php?/topic/25484-making-complex-program-goals-manageable/

Also, if you are running your code in a single player world then you can directly access the files of computercraft computers via your minecraft saves folder.
Assuming you are using the vanilla launcher, click on launch options at the top (if you can't see this then click on the hamburger icon in the top right). Next click on the instance which you normaly play, then click on the arrow on the right of the game directory section. Open the saves directory , then the world name. The folder named 'computer' is where computercraft keeps all of the files saved on the computers in the mod, the numbers are the IDs of the computers, inside these folders is that computer's file system, you should be able to open any file with a text editor - such as notepad++ (Note: Depending on which version of computercraft you are using, the files in the computercraft file system may or may not have file exstentions, this may mean that Windows will not know what to do with the files, I find that rightclicking and choosing "edit with notepad++" is the easiest option in the case that the files have no extention.)