Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Macro Mod basic syntax
- // NOTE: Macro mod does not require ";" at the end of a line. It IS required in almost every other language, so it's good habit to use it.
- // Comment tags
- // This is a comment
- This is also a comment. // Weird, right?
- command(); // This is a comment, but the command is executed as code.
- // Statements
- if(stuff);
- //stuff
- elseif(morestuff);
- //stuff
- else;
- //stuff
- endif;
- // Variables:
- // Environment
- %ENVIRONMENTAL_STRING%
- %ENRIVONMENTAL_INTEGER%
- ENRIVONMENTAL_BOOLEAN
- // Here's a list of all environmental variables: http://mkb-wiki.herokuapp.com/wiki/variables
- // Defining variables:
- // There are 3 types of user-defined variables: integer, string, and boolean
- // Variables cannot use uppercase!
- // I hate this about Macro Mod, it's bad practice. Invert this for real languages.
- // Wrong
- #varName = 42;
- // Right
- #varname = 42;
- // Local (to the current script, NOT the current block)
- &string = "string";
- #integer = 42;
- boolean = true;
- // Global (to all scripts, NOT including other Minecraft clients on the same computer)
- @&global_string = "string"
- @#global_integer = 42
- set(@boolean)
- unset(@boolean)
- // set/unset can also be used as well
- set(&string,"set string to this");
- set(#integer,42);
- set(boolian);
- // When referencing a variable, surround it with %%, EXCEPT when evaluating it
- &string = "local string";
- log(%&string%);
- if(&string == "local string");
- // Do stuff
- endif;
- // Remember, @ is necessary when referencing a global variable!
- @&gstring = "Global string";
- log(%@&gstring%);
- // Contrary to all logic, variables can be referenced inside quotations.
- // Quotations are essentially identical to lua's tostring method, which is really odd. For example:
- #variable = 42;
- log("%#variable%");
- // ..is identical to the following in lua:
- local variable = 42;
- print(tostring(variable));
- // The same goes for statements
- #var1 = 42;
- &var2 = "42";
- // This will return true
- if("%#var1%" == %&var2%); // Note the quotations around %#var1%, this turns it into a string.
- log("True!");
- else;
- log("False!");
- endif;
- // This will return false
- if(%#var1% == %&var2%);
- log("True!");
- else;
- log("False!");
- endif;
- // Loops:
- // Normal loop
- do;
- //stuff
- loop;
- // Loop x times
- do(x);
- //stuff
- loop;
- // FOR loop
- for(#iterator,%#start%,%#finish%);
- //stuff
- next;
- // FOREACH
- // http://mkb-wiki.herokuapp.com/wiki/iterators
- // Logs name of each player to chat
- foreach(players,¤t_player);
- log(%¤t_player%);
- next;
- // Arrays can be iterated with foreach as well. Reference the array as "arrayname" with no additional symbols.
- // Split string into array with delimiter ","
- &string = "p1,p2,p3,p4";
- &arrayname = split(",",%&string%);
- // Log each iteration to chat
- foreach(arrayname,¤t_iteration);
- log(%¤t_iteration%);
- next;
- Here's a list of all commands: http://mkb-wiki.herokuapp.com/wiki/commands
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement