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:
Alternatives: FORWARDS, FWD, FOR, FO, FD, F
BACK - Moves the turtle back one block or by a number given.
Alternatives: BACKWARD, BACKWARDS, BK, BA, B
UP - Moves the turtle up one block or by a given number.
Alternatives: UPWARD, UPWARDS, U, RISE
DOWN - Moves the turtle down one block or by a given number.
Alternatives: DOWNWARD, DOWNWARDS, DN, DO, D, LOWER, LWR, FALL
LEFT - Turns the turtle left once or as many times specified.
Alternatives: LFT, LT, LE, L
RIGHT - Turns the turtle right once or as many times specified.
Alternatives: RT, RI, R
DIG - Makes the turtle dig. Use AHEAD (Default), FRONT, F, UP, ABOVE, U, A, TOP, T, DOWN, D, BELOW, BOTTOM, B
Alternatives: DG, DI
PLACE - Places a block from the current inventory slot. Use the same directions as DIG.
Alternatives: PL, P
DROP - Drop items in a direction (same as DIG directions) and optionally a number of items to drop or ALL for everything in the inventory.
Alternatives: DRP, DP, DR
SUCK - Sucks dropped items from a direction (same as DIG) and optionally a number of items to suck up.
Alternatives: SK, SU, S, GRAB, GR, GET, GT, GE, G
SELECT - Selects an inventory slot. Provide a slot number 1 to 16.
Alternatives: SEL, SL, SE, INVENTORY, INV, IN, I
DETECT - Detects if there is something in a direction specified (directions as with DIG). In scripting it can be used with the IF command to do conditional commands.
Alternatives: DTCT, DCT, DT, DE, SENSE, SEN
ATTACK - Attacks the space in the direction specified (again same directions as in DIG :)/> )
Alternatives: ATK, AT, A, HIT, HT, H
EQUIP - Equips a tool from the currently selected inventory slot. Specify LEFT or RIGHT for the side to equip to.
Alternatives: EQP, EQ, E, USE
REFUEL - Refuels the turtle. Without a parameter it refuels using all items in the currently selected slot. If a number is given
it will only use that many from the slot. If ALL is specified then it will go through all slots to use all available items.
Alternatives: REF, RFL, RF
FUEL - Checks the current fuel level. Can not use this in scripts yet.
Alternatives: FL, FU
REPEAT - Can only be used in scripts. Repeats the next command in the script a specified number of times.
[ - Marks the start of a block of commands in a script to be repeated together by the REPEAT command. If used without a REPEAT then it is ignored.
] - Marks the end of the block of commands. If used without a REPEAT then it is ignored.
RUN - Runs a script
EDIT - Edits/creates a script file. It calls the ComputerCraft EDIT program and automatically adds the 'turtle.' prefix to the script name. The only time you should need to supply the 'turtle.' prefix is if you are editing the script file outside of the Turtle program.
Alternative: ED
LIST - Lists the scripts available to RUN or EDIT.
Alternatives: LS, DIR, FILES, SCRIPTS
PRINT - Displays whatever is provided after the print command on the turtle's screen.
Alternatives: ECHO, WRITE, SAY, PR, EC, WR
EXIT - Returns you to the TurtleOS prompt.
Alternatives: EX, X, QUIT, QT, Q, END
Released Version Changes:
Todo list:
Example script (for when the scripting is implemented) to dig a horizontal tunnel 40 blocks deep, 3 blocks wide and 3 blocks high:
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
FORWARD - Moves the turtle forward one block or by a number given.Alternatives: FORWARDS, FWD, FOR, FO, FD, F
BACK - Moves the turtle back one block or by a number given.
Alternatives: BACKWARD, BACKWARDS, BK, BA, B
UP - Moves the turtle up one block or by a given number.
Alternatives: UPWARD, UPWARDS, U, RISE
DOWN - Moves the turtle down one block or by a given number.
Alternatives: DOWNWARD, DOWNWARDS, DN, DO, D, LOWER, LWR, FALL
LEFT - Turns the turtle left once or as many times specified.
Alternatives: LFT, LT, LE, L
RIGHT - Turns the turtle right once or as many times specified.
Alternatives: RT, RI, R
DIG - Makes the turtle dig. Use AHEAD (Default), FRONT, F, UP, ABOVE, U, A, TOP, T, DOWN, D, BELOW, BOTTOM, B
Alternatives: DG, DI
PLACE - Places a block from the current inventory slot. Use the same directions as DIG.
Alternatives: PL, P
DROP - Drop items in a direction (same as DIG directions) and optionally a number of items to drop or ALL for everything in the inventory.
Alternatives: DRP, DP, DR
SUCK - Sucks dropped items from a direction (same as DIG) and optionally a number of items to suck up.
Alternatives: SK, SU, S, GRAB, GR, GET, GT, GE, G
SELECT - Selects an inventory slot. Provide a slot number 1 to 16.
Alternatives: SEL, SL, SE, INVENTORY, INV, IN, I
DETECT - Detects if there is something in a direction specified (directions as with DIG). In scripting it can be used with the IF command to do conditional commands.
Alternatives: DTCT, DCT, DT, DE, SENSE, SEN
ATTACK - Attacks the space in the direction specified (again same directions as in DIG :)/> )
Alternatives: ATK, AT, A, HIT, HT, H
EQUIP - Equips a tool from the currently selected inventory slot. Specify LEFT or RIGHT for the side to equip to.
Alternatives: EQP, EQ, E, USE
REFUEL - Refuels the turtle. Without a parameter it refuels using all items in the currently selected slot. If a number is given
it will only use that many from the slot. If ALL is specified then it will go through all slots to use all available items.
Alternatives: REF, RFL, RF
FUEL - Checks the current fuel level. Can not use this in scripts yet.
Alternatives: FL, FU
REPEAT - Can only be used in scripts. Repeats the next command in the script a specified number of times.
[ - Marks the start of a block of commands in a script to be repeated together by the REPEAT command. If used without a REPEAT then it is ignored.
] - Marks the end of the block of commands. If used without a REPEAT then it is ignored.
RUN - Runs a script
EDIT - Edits/creates a script file. It calls the ComputerCraft EDIT program and automatically adds the 'turtle.' prefix to the script name. The only time you should need to supply the 'turtle.' prefix is if you are editing the script file outside of the Turtle program.
Alternative: ED
LIST - Lists the scripts available to RUN or EDIT.
Alternatives: LS, DIR, FILES, SCRIPTS
PRINT - Displays whatever is provided after the print command on the turtle's screen.
Alternatives: ECHO, WRITE, SAY, PR, EC, WR
EXIT - Returns you to the TurtleOS prompt.
Alternatives: EX, X, QUIT, QT, Q, END
Released Version Changes:
Spoiler
Version 0.13 beta:- Now checks if being run in a turtle! (Should have added this from the start!!)
- Added the PRINT command
- More 'behind the scenes' code changes
- Added the DROP command
- Changed the SUCK command to also allow specifying a number of items
- Code changes not noticeable to the user!
- Added LIST command to list the scripts on disk.
- Added EDIT command to edit scripts.
- Added script running support.
- Added support for the REPEAT command in scripts.
- Added command block marking with [ and ] for repeating more than one command.
- Tidied some of the code for script running with regards to errors.
- Created the core functionality of the program.
- Added all the main commands with the exception of DROP.
Todo list:
Spoiler
Next planned changes, these may not be in the next release but once these are done it will be out of beta:- Add a HELP system for the commands.
- Add the IF command for use in scripts.
- Add nested command blocks for use of IF or REPEAT inside a block.
- Add simple variable support and checking in IF.
- Add argument support to scripts.
Example script (for when the scripting is implemented) to dig a horizontal tunnel 40 blocks deep, 3 blocks wide and 3 blocks high:
Spoiler
REPEAT 40
[
DIG
FORWARD
LEFT
DIG
DIG UP
UP
DIG
DIG UP
UP
DIG
RIGHT 2
DIG
DOWN
DIG
DOWN
DIG
LEFT
]
Edited on 01 April 2015 - 06:56 PM