Jump to content




Trying to tidy up a remote turtle mining/mapping script, new to lua


5 replies to this topic

#1 skyeyemachine

  • New Members
  • 10 posts

Posted 25 April 2012 - 05:23 AM

Hello all,

Firstly, I found a program I am really excited about; it allows me to control a turtle remotely and have it map out its path on a 2D map. However, it's coded quite cryptically, and I've also tried to expand its functions a bit. The resulting program runs, but I seem to have botched something, as the turtle behaves erratically. I'm new to lua and programming in general, but I've been careful, and I can't seem to pick out where my error(s) lie.

If anyone cares to take a look, I'd appreciate any help in tracking my bugs.

The original, for the turtle and terminal respectively;

Spoiler

Spoiler


And my versions (mostly an attempt to clarify exactly what's going on), turtle and terminal respectively. I've added three new functions and appended/changed the keymap a little, but beyond that, I've tried to leave everything essentially the same, just easier to read. Note that my variable names may not be entirely appropriate; I'm still figuring this program out:

Spoiler

Spoiler


Any suggestions are welcome.

#2 libraryaddict

  • New Members
  • 195 posts

Posted 25 April 2012 - 07:17 AM

You can use spoilers :)/>
Spoilers will turn off the headache of spam

#3 skyeyemachine

  • New Members
  • 10 posts

Posted 25 April 2012 - 08:03 AM

Ah, sorry, will do so next time. Can't seem to edit my first post.

#4 skyeyemachine

  • New Members
  • 10 posts

Posted 25 April 2012 - 12:36 PM

Oh, I should mention for anyone who tests; it came with no instructions, so I had to figure it out myself, but the "ID" at the start of each program is the computer ID for the other machine in the pair (so on the computer, you enter the turtle ID, and on the turtle, the computer ID). Maybe that's obvious to more experienced coders, but I wasn't sure what it wanted at first.

#5 skyeyemachine

  • New Members
  • 10 posts

Posted 25 April 2012 - 07:58 PM

Incidentally, since the map it generates is 2D, I added a simple hack for vertical movement; the map is cleared upon an attempt to move upwards or downwards. If anyone has any suggestion for how I might make a multiple-level map, with the display cycling through each layer of terrain as it moves up and down, please let me know, as that would be much more ideal.

#6 OmegaVest

  • Members
  • 436 posts

Posted 25 April 2012 - 10:29 PM

First: put code tags inside the spoiler, please. +1 for spoiler-tagging, though.
Second, have the maps generate/save on multiple files. Each map would be in a folder ("maps"..turtleNum), within would be a bunch of levels. To call each, know your depth/height, then call like so:
Spoiler

It's a horrible way to do so, but would probably help in the long run. And, hopefully this will help a bit.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users