Jump to content




Turtle Prompt/Scripting


7 replies to this topic

#1 Galbi3000

  • Members
  • 22 posts

Posted 15 March 2015 - 02:19 AM

Hi,

Here is my first submission of a program to this forum :)

Turtle is currently in version 0.10 beta and has a few missing features. I will update this page with any changes.

The purpose of this program is to provide a simpler scripting language for people new to programming to learn so they can make better use of their turtles without the hassle of learning Lua commands, APIs, etc. :)

Scripts are stored in the same folder (directory) as the Turtle program and have a prefix of 'turtle.' which will not need to be added in the RUN or EDIT commands or at the TurtleOS prompt as a parameter of Turtle. For example a script file named turtle.buildHouse will be run either by typing at the TurtleOS prompt 'turtle buildHouse' or in the Turtle prompt with the command 'RUN buildHouse'. This is just so you do not try to run the script as a Lua program :)

The pastebin code is MzzhiwNe or download direct from http://pastebin.com/MzzhiwNe


The commands it currently supports:
Spoiler

Released Version Changes:
Spoiler

Todo list:
Spoiler

Example script (for when the scripting is implemented) to dig a horizontal tunnel 40 blocks deep, 3 blocks wide and 3 blocks high:
Spoiler

Edited by Galbi3000, 01 April 2015 - 07:56 PM.


#2 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 15 March 2015 - 02:31 AM

Interesting concept, looks well implemented


Didn't try so can't report any bugs for you. Just one question from glancing at the code:

Why do you remove tabs from the user input? I don't even think MC supports the tab character, I can't think of a place it can be typed

#3 Galbi3000

  • Members
  • 22 posts

Posted 15 March 2015 - 02:35 AM

View PostHPWebcamAble, on 15 March 2015 - 02:31 AM, said:

Interesting concept, looks well implemented


Didn't try so can't report any bugs for you. Just one question from glancing at the code:

Why do you remove tabs from the user input? I don't even think MC supports the tab character, I can't think of a place it can be typed

It is a 'just in case' scenario. As ComputerCraft programs can be edited outside of Minecraft using ordinary or programmer specific text editors (that's how I edit/create mine) then there could be a possibility of a tab getting in there for scripts. But yeah, I see your point for the prompt entry. I think I had intended the code to process lines of the script files as well but changed my mind after I wrote that bit :)

#4 Galbi3000

  • Members
  • 22 posts

Posted 15 March 2015 - 09:22 PM

New version available. See the OP for details :)

#5 Galbi3000

  • Members
  • 22 posts

Posted 16 March 2015 - 10:33 PM

New version 0.10 beta released. See OP for details :)

#6 Galbi3000

  • Members
  • 22 posts

Posted 01 April 2015 - 06:44 PM

Another small update released. Version 0.12 beta. Added the PRINT command to allow scripts to display messages on the screen. See OP for full details on the command :)

The help system and IF command are still in the pipeline. It's just that other real world things have taken a temporary priority :wacko:

*EDIT*
Very minor release update to 0.13 beta. Now includes checking if running on a turtle! I know, should have added that check in the first version! It totally slipped my mine until now :D

Edited by Galbi3000, 01 April 2015 - 07:58 PM.


#7 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 01 April 2015 - 07:20 PM

Looks nice!

By looking at the code, I'm not entirely sure if nested loops would work.
I mean something like this:
REPEAT 20
[
  UP
  REPEAT 5
  [
    FORWARD
  ]
]

Edited by Freack100, 01 April 2015 - 08:18 PM.


#8 Galbi3000

  • Members
  • 22 posts

Posted 01 April 2015 - 08:05 PM

View PostFreack100, on 01 April 2015 - 07:20 PM, said:

Looks nice!

By looking at the code, I'm not entirely sure if nested loops would work.
I mean something like this:
REPEAT 20
[
  UP
  FORWAR
]
Yes, currently the Lua code does not provide support for nested loops. It is a messy part of the whole program, an untidy workaround to get the looping working in an early beta form. I will need time to plan how to do it correctly in a way that would allow nesting but currently real life issues are getting in the way :angry:

The way nested loops would work would be something like:

REPEAT 5
[
  UP
  REPEAT 4
  [
	REPEAT 4
	[
	  FORWARD
	  PLACE DOWN
	]
	RIGHT
  ]
]

Which would (if I included nested looping support) build 4 walls of 5x5 making an open topped box. Such code could be the base for building a house.
But like I said, I would have to build in support for nested loops for such code to work :)

*EDIT* PS, Yes I realise the sample code above would fail to build the walls fully as it would run out of blocks before finishing. It's just a theoretical code sample not actual code that would work as is ;)

Edited by Galbi3000, 01 April 2015 - 08:16 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users