Turtles

Jan 22, 2016
Turtles
  • Turtles wiki
    -------------------------------------------------------------------------------------------------------------------------------------------------------

    » How to craft a turtle?

    [​IMG]

    » Learn TurtleScript code

    TurtleScript is easy to learn. Only need to put at the end of every command a semicolon.

    The main plugin comes with 8 commands, you can grow this number with addons.
    » Print
    • Print a message to the owner of the turtle.
    • Usage » print <message>;
    » Move
    • Move the turtle to a direction.
    • Usage » move <up/down/north/south/east/west>;
    » Dig
    • The turtle dig a block.
    • Usage » dig <up/down/north/south/east/west>;
    » Select
    • Select an item from turtle's bag.
    • Usage » select <0-8>;
    » Place
    • The turtle place the selected block.
    • Usage » place <up/down/north/south/east/west>;
    • Require » Selected item.
    » Drop
    • The turtle drops the selected item.
    • Usage » drop;
    • Require » Selected item.
    » Suck
    • Pick an item from the ground.
    • Usage » suck <up/down/north/south/east/west>;
    » Goto
    • Jump to another line from the code.
    • Usage » goto <line (0-...)>;

    » Placeholders
    » Block type
    • Get the block type.
    • Usage » %block <up/down/north/south/east/west> type%
    » Owner
    • Get the name/UUID from the owner.
    • Usage » %owner <name/uuid>%

    » Extend TurtleScript with custom commands
    » Main class

    Code (Text):
    package com.dootie.turtles;

    import com.dootie.turtles.executer.CommandResolver;
    import org.bukkit.plugin.java.JavaPlugin;

    public class HelloTurtle extends JavaPlugin {

        @Override
        public void onEnable() {
            // Register the command
            CommandResolver.commands.put("hello", new CommandHello());
        }
    }
    » Command class
    Code (Text):
    package com.dootie.turtles;

    import com.dootie.turtles.executer.Executer;
    import com.dootie.turtles.executer.command.Command;


    public class CommandHello extends Command {

        @Override
        public void execute(Executer executer, String[] arguments){

            if(arguments.length > 0){
                // Send an error
                executer.getTurtle().sendError("Too many arguments");
                // If it's a big error you can cancel the script execution with
                executer.stop();
            }else{
                // Print hello to the owner
                executer.getTurtle().sendMessage(" Hello!");
            }
        }
    }
    » Ingame book
    Code (Text):
    # Return Hello;
    hello;
    # Return an error;
    hello invalid arguments;
    » Extend TurtleScript with custom placeholders
    »
    Main class

    Code (Text):
    package com.dootie.turtles;

    import com.dootie.turtles.executer.PlaceholderResolver;
    import org.bukkit.plugin.java.JavaPlugin;

    public class HelloTurtle extends JavaPlugin {

        @Override
        public void onEnable() {
            // Register the placeholder
            PlaceholderResolver.placeholders.put("%hello%", new PlaceHello());
        }
    }
    » Placeholder class
    Code (Text):
    package com.dootie.turtles;

    import com.dootie.turtles.repository.Turtle;
    import com.dootie.turtles.executer.placeholders.Placeholder;


    public class PlaceHello extends Placeholder {

        @Override
        public String execute(Turtle turtle){
            return "Hello";
        }
    }
    » Ingame book
    Code (Text):
    # Return Hello
    print %hello%;
  • Loading...
  • Loading...