Jump to content




[Lua]Miner Stops at Identified

turtle computer lua

7 replies to this topic

#1 Will11690

  • Members
  • 7 posts

Posted 10 April 2018 - 12: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

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 10 April 2018 - 01: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.

#3 Will11690

  • Members
  • 7 posts

Posted 10 April 2018 - 02: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.

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 10 April 2018 - 03: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.

#5 Will11690

  • Members
  • 7 posts

Posted 10 April 2018 - 12: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 by Will11690, 10 April 2018 - 12:20 PM.


#6 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 10 April 2018 - 01: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.

#7 Purple

  • Members
  • 115 posts
  • LocationAlone in the dark, looking at the pretty lights with dreams of things I can not have.

Posted 10 April 2018 - 01:58 PM

Just make sure to engage Lua formatting in notepad++.

#8 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 10 April 2018 - 06:41 PM

I think you may find this helpful: http://www.computerc...als-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.)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users