Jump to content




Basic Structures


1 reply to this topic

#1 _The_Big_Red_

  • New Members
  • 1 posts

Posted 26 March 2014 - 02:56 PM

I have really appreciated the ComputerCraft mod as part of the Direwolf20 modpack. I've spent a bit of time building a few programs that I thought were worth sharing back to the community. It's not the best code I've ever written but LUA is a new language to me so I'm learning as I go. There are a few things that could use some work but over all it's functional. If you have a suggestion on how to improve, feel free to update the code and if it makes sense to me, I'll update the originals.

My general thought process is that I've built reusable libraries to do the bulk of the work and then written smaller programs to use those libraries to accompllish meaningful things which speeds up my ability to make new programs. As a convention, all of my programs expect slot number 15 to contain fuel and only uses what's necessary as needed. If it needs fuel and does not have any in slot 15, it will simply wait until fuel is added then continue where it left off. To get started, download the 'update' program from pastebin:

pastebin get 16Fi7BAZ update

This program is used to fetch all other programs. I wrote it because I got tired of looking up pastebin IDs every time I modified

code. To use it, simply run:

update <ProgramName>

For example, if there have been updates to the update program, you would run "update update". Installing new programs are done using the same command providing that program has been registered in the update program. (ie: update makefloor to install the makefloor program)

The first place to start is to fetch all of the libraries as nearly every program I write uses them. The easiest thing to do is to update all libraries:

update lib all

Here are the help files for some key programs I've written. If in doubt, you can always execute the program with no arguments for a reminder on how to use it.

turn [right|left|around]
Turns the turtle in place

go [up|down|forward|backward] <distance>
Moves a specified direction a giiven number of places

makewall <length> <height>
Builds a wall using the items in inventory slots nubmer 1 thru 13. If it runs out of items, it will wait for you to refill.

makefloor <length> <width> [right|left]
Makes a floor (or flat roof) of a givenlength and width using the items in inventory slots nubmer 1 thru 13, building the

square to the right or left of the turtle's starting position. If it runs out of items, it will wait for you to refill.

makebox <length> <width> <Height> [right|left]
Makes a box of given dimensions. Exacly like making 4 walls in a single command (I got tired of repositioning the turtle for my next wall)

dig [top|front|bot]
If you have a mining Turtle, this will break the block in the given direction and add it to inventory. Great way to fetch things out of lava.

digline <length> [top|front|bot]
Digs in a straight line of given length, removing all blocks in the given direction (above, below, or in front of the turtle) There's still alot to be desired on this one; I wrote it real quick when I accidently placed down a large wall in the wrong place.

If you want to take a look at my code, the pastebin IDs are all in the first few lines of the update program but here's the current list. Should be easy enough to add your own programs but those changes will be overwritten if you update update. I hope to change the update program to use a seperate text file in the future so that you can add your own custom list that will not be overwritten but have not begun to work on that yet:

Spoiler


#2 silicon1

  • New Members
  • 1 posts

Posted 28 October 2014 - 05:52 PM

I've tried to use your makefloor program, I tried using advanced turtle and normal turtle, mining turtle, etc. I put a lava bucket in slot 16, some cobblestone in slot 1 and then run the program "makefloor 5 5 right" (after doing update, update lib al) the turtle uses the lava, puts down one block and says "CAN'T MOVE!!!" and reboots itself.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users