Advertisement
Sanwi

Macro Mod syntax guide

Apr 21st, 2015
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. // Macro Mod basic syntax
  2.  
  3. // 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.
  4. // Comment tags
  5. // This is a comment
  6. This is also a comment. // Weird, right?
  7. command(); // This is a comment, but the command is executed as code.
  8.  
  9. // Statements
  10.  
  11. if(stuff);
  12. //stuff
  13. elseif(morestuff);
  14. //stuff
  15. else;
  16. //stuff
  17. endif;
  18.  
  19. // Variables:
  20. // Environment
  21. %ENVIRONMENTAL_STRING%
  22. %ENRIVONMENTAL_INTEGER%
  23. ENRIVONMENTAL_BOOLEAN
  24.  
  25. // Here's a list of all environmental variables: http://mkb-wiki.herokuapp.com/wiki/variables
  26.  
  27. // Defining variables:
  28. // There are 3 types of user-defined variables: integer, string, and boolean
  29.  
  30. // Variables cannot use uppercase!
  31. // I hate this about Macro Mod, it's bad practice. Invert this for real languages.
  32. // Wrong
  33. #varName = 42;
  34.  
  35. // Right
  36. #varname = 42;
  37.  
  38. // Local (to the current script, NOT the current block)
  39.  
  40. &string = "string";
  41. #integer = 42;
  42. boolean = true;
  43.  
  44. // Global (to all scripts, NOT including other Minecraft clients on the same computer)
  45.  
  46. @&global_string = "string"
  47. @#global_integer = 42
  48. set(@boolean)
  49. unset(@boolean)
  50.  
  51. // set/unset can also be used as well
  52.  
  53. set(&string,"set string to this");
  54. set(#integer,42);
  55. set(boolian);
  56.  
  57. // When referencing a variable, surround it with %%, EXCEPT when evaluating it
  58.  
  59. &string = "local string";
  60. log(%&string%);
  61. if(&string == "local string");
  62. // Do stuff
  63. endif;
  64.  
  65. // Remember, @ is necessary when referencing a global variable!
  66.  
  67. @&gstring = "Global string";
  68. log(%@&gstring%);
  69.  
  70. // Contrary to all logic, variables can be referenced inside quotations.
  71. // Quotations are essentially identical to lua's tostring method, which is really odd. For example:
  72.  
  73. #variable = 42;
  74. log("%#variable%");
  75.  
  76. // ..is identical to the following in lua:
  77.  
  78. local variable = 42;
  79. print(tostring(variable));
  80.  
  81. // The same goes for statements
  82.  
  83. #var1 = 42;
  84. &var2 = "42";
  85.  
  86. // This will return true
  87. if("%#var1%" == %&var2%); // Note the quotations around %#var1%, this turns it into a string.
  88. log("True!");
  89. else;
  90. log("False!");
  91. endif;
  92.  
  93. // This will return false
  94. if(%#var1% == %&var2%);
  95. log("True!");
  96. else;
  97. log("False!");
  98. endif;
  99.  
  100. // Loops:
  101.  
  102. // Normal loop
  103.  
  104. do;
  105. //stuff
  106. loop;
  107.  
  108. // Loop x times
  109.  
  110. do(x);
  111. //stuff
  112. loop;
  113.  
  114. // FOR loop
  115.  
  116. for(#iterator,%#start%,%#finish%);
  117. //stuff
  118. next;
  119.  
  120. // FOREACH
  121. // http://mkb-wiki.herokuapp.com/wiki/iterators
  122.  
  123. // Logs name of each player to chat
  124. foreach(players,&current_player);
  125. log(%&current_player%);
  126. next;
  127.  
  128. // Arrays can be iterated with foreach as well. Reference the array as "arrayname" with no additional symbols.
  129.  
  130. // Split string into array with delimiter ","
  131. &string = "p1,p2,p3,p4";
  132. &arrayname = split(",",%&string%);
  133.  
  134. // Log each iteration to chat
  135. foreach(arrayname,&current_iteration);
  136. log(%&current_iteration%);
  137. next;
  138.  
  139. Here's a list of all commands: http://mkb-wiki.herokuapp.com/wiki/commands
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement