Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Macro/Keybind Mod API
- This is an unofficial documentation of the mod written with help of inspecting it's code and of my own experience
- ## REPL console actions
- ```
- TODO
- ```
- ## Expressions
- Seems like you can write expressions like in normal programming language
- **Algebraic operators:**
- - `+`
- - `-`
- - `*`
- - `/`
- **Conditional operators:**
- - `=`, `==` - both check if values are equal
- - `!=`
- - `<=`, `>=`
- - `<`, `>`
- - `&`, `&&` - both mean regular AND operator
- - `|`, `||` - both mean regular OR operator
- ## Special blocks
- #### Conditions
- - `If(expression);`
- - `IfBeginsWith(%&subject%, %&pattern%);`
- - `IfContains(%&subject%, %&pattern%);`
- - `IfEndsWith(%&subject%, %&pattern%);`
- - `IfMatches(%&subject%, %&pattern%, [&output_var], [%#group_number%]);` - if `#group_number` is specified then the exact group is written to `&output_var` (range is `[0,group_count]`)
- - `Else;`
- - `ElseIf(expression);`
- - `EndIf;`
- #### Loops
- ##### Common actions
- - `Break;` - breaks current loop
- ##### DO->LOOP/UNTIL/WHILE loop
- - `Do([%#count%]);` - Starts the loop. `#count` limits the loop to specified amount of cycles
- - `Loop; Until; While;` - End the loop
- ##### FOR->NEXT loop
- - `For(<#counter>,<%#start%>,<%#end%>,[%#step%]);`
- - `ForEach(<iterator>);` - `TODO`
- - `Next;`
- ##### Unsafe block
- Regularly actions are called with a small delay. To remove that delay wrap the code in this block.
- **Syntax:**
- - `Unsafe(%#max_actions%);` - Starts the block. `#max_actions` defaults to `100`, max is `10000`
- - `EndUnsafe;`
- ## Array actions
- | Syntax | Return | Parameters | Description |
- |--------|--------|------------|-------------|
- | `ArraySize([array_var[]], [#size_var]);` | Specified array's length | | Returns 0 if no array specified |
- | `IndexOf([&array_var], [#index_var], [%&search_value%], [case_sensitive]);` | Index of specified element in the array | | |
- | `Pop([&array_var], [&popped_value_var]);` | Popped value | | Pops last value from the array |
- | `Push([&array_var], [%&value_to_push%]);` | None | | Pushes specified value to the array |
- | `Put([&array_var], [%&value_to_put%]);` | None | | Adds specified value to the array at the first empty index in it. If no such index exists acts like `Push` action |
- ## Other actions
- ### net.eq2online.macros.scripting.actions.lang
- | Syntax | Return | Parameters | Description | Permission group |
- |--------|--------|------------|-------------|------------------|
- | `Assign([target_var], [%value%]);` | The value set to the variable | `target_var` defaults to `flag`, `value` defaults to an empty string | If specified target is an array the function pushes the value to the array instead |
- | `CalcYawTo([%x%], [%z%], [&yaw_var], [&distance_var]);` | Calculated yaw | `x`, `z` default to 0 | Calculates yaw to specified block with x,z coordinates. Also can calculate distance to this point |
- | `Dec([#counter_var], [%#amount%]);` | | `#counter_var` defaults to `counter`, `#amount` defaults to `1` | Decreases value of specified variable by specified amount |
- | `Decode([%&input%], [&output]);` | Decoded string | `&input` defaults to an empty string | Decodes Base64-encoded string. Returns empty string if it was unable to decode the string |
- | `Do([%#count%]);` | | `#count` limits the loop to specified amount of cycles | Starts loop |
- | `Echo(%&msg%);` | Sent message | Parameters aren't parsed, so they are all sent to chat | Sends specified messages to chat | `chat` |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement