Macros Mod for Minecraft - Readme for version 0.8.5 --------------------------------------------------- This mod adds key binds to Minecraft, it requires ModLoader which you will find at http://www.minecraftforum.net/topic/75440-risugamis-mods/ To install the mod: 1) Download and install ModLoader in your minecraft.jar 2) Create a folder called "mods" under your minecraft folder if it doesn't already exist and put the .zip file in there. 3) Run minecraft! To use the mod: This mod works in both single player and multiplayer, although "Single Player Commands" is recommended if using the mod in single player Getting started with the mod, configuring your keys --------------------------------------------------- This mod uses two keys for its functions (besides the keys you bind), these are the key which is used to bind and play back macros, and the key which is used to override a key's normal function to allow you to quickly play a macro. The very first thing you should do when you install the mod is configure these keys to your liking. From the minecraft menu open the "Options" and then "Controls" and you should notice that you now have extra buttons in your "Controls" menu which look like << and >>. Go to the second page and configure your keys to use the mod. Getting started with the mod, binding keys: ------------------------------------------- 1) To activate MACRO BIND mode, you should hold down your key and press the key which defaults to the apostraphe/grave key. You can change the key in the Minecraft options. 2) Once you have activated MACRO BIND mode, simply press a key to bind, or alternatively click a key on the on-screen keyboard. Keys are displayed on-screen as follows: Grey keys - are not bound to any function Red keys - are used for other minecraft functions (they can still be bound) Yellow keys - are bound to a macro Orange keys - are minecraft keys which ALSO have a bound macro Green keys - are global macros (available in all configurations - see below) You can also bind the left, right and middle mouse buttons 3) Enter your key bind commands, separate multiple commands/messages with the pipe symbol "|". Press "Options..." to set modifiers and options for the macro (for example to require , or to be pressed. 3) When you're done, press or click "Save". To use a keybind: ----------------- 1) Press the key alone, then press the key. 2) If a key is not bound to another function, you can simply press the key itself to execute the macro. 3) If a key DOES have another function, you can hold the key (default is ) to temporarily override the key's normal function and execute the macro instead. To edit a keybind: ------------------ 1) Enter MACRO BIND mode as described above. 2) To delete a macro, click "Delete" and click on the key. THIS ACTION CANNOT BE UNDONE AND THERE IS NO PROMPT TO CONFIRM THE DELETION. 3) To move a macro, click "Move" then drag from the source key to the destination. If the destination key already contains a macro it will be overwritten. 4) To copy a macro, click "Copy" then drag from the source key to the destination. If the destination key already contains a macro it will be overwritten. 5) To edit a macro, click the key on screen or press the key on your keyboard. Using parameters in your macros: -------------------------------- Parameters are a powerful feature of this mod which allow you to dynamically alter your macro when you use it, for example to insert a player's name, an amount, an item number or whatever you like. Use the following codes in your macros to provide prompts when you run the macro: $$? Is a general parameter, use this anywhere in your macro to substitute some text at that point. $$i Is an item parameter, use this to prompt for an item id - the mod will provide a scrollable list of items when prompting. $$i:d Is the same as a normal item parameter, but also sends the damage value of the selected item for mods which support this, allowing you to for example select coloured wool. $$f Is a friend parameter, you can maintain a list of friends which can be inserted in your macros. $$u Is an online user parameter, provides a list of online users when executing the macro. $$t Is a town name parameter, you can maintain a list of towns. $$h Is a home name parameter, use this to keep a list of your homes. $$0 to $$9 Are "preset text list" parameters, you can use up to 10 lists of text which can be recalled at any time and can include parameters within them too. You could use this for any arbitrary text such as help, advertisements, or other announcements. $$[name] Replace "name" with any text to prompt for a named parameter, this allows a large number of possible parameters in your macros. $$ Enter the name of a text file to include the entire text file in your macro. $$m Like the previous $$ parameter, but prompts for the file when executing the macro. $$w Is a warp parameter, use this for warp points $$p Is a "place" parameter, this stores X, Y and Z coordinates and inserts them in your macro. You can also use $$px Insert the X coordinate of a "place" parameter $$py Insert the Y coordinate of a "place" parameter $$pz Insert the Z coordinate of a "place" parameter $$pn Insert the name of a "place" parameter Directives in your macros: -------------------------- Currently the macro processor only supports one directive. Including $$! at the end of your macro instructs the macro processor to terminate but to pump the contents of the last message into the chat buffer. For example, using the following macro /say this is a test|/say this is another $$! Will send the first command "/say this is a test" to the server, and then put the remaining text "/say this is another " into the chat buffer for you to complete. Note that macro processing always terminates at $$! and any instructions after the directive are ignored. Multiple configurations and global keys: ---------------------------------------- From version 0.5, the mod supports multiple configurations allowing you to have different macro keys on different servers or in single player versus multiplayer. The number of allowed configurations is unlimited, and when you start you will be using a configuration called "Default Configuration", this configuration can not be deleted or renamed. Configurations can be set up to automatically switch by naming them the same as the server's dns hostname, this can be easily found by clicking the "Use current server address" button when creating a new configuration. To access the configuration selection screen: 1) Either press + twice, or press it once and then click the label which indicates the current configuration name at the top of the screen. As well as choosing existing configurations and creating new ones, you can also alter some of the mod settings through this screen. To create a new configuration: 1) Click the "" entry at the bottom of the configurations list 2) Enter a name for the new configuration or click the "Use current server address" button to detect the hostname of the current server (note that this may be different to the address you connected to). 3) To copy all of the keys from the currently active configuration, check the option. Obviously whilst you may wish for some of your keys to vary between servers, you may wish some keys to always have the same function. Rather than copying these keys to all configurations, you can choose to make the binding "global" which makes its behaviour persist regardless of the currently selected configuration. To make a key "global": 1) Edit the key macro as normal. 2) Click "Options..." 3) Check the option "Apply to all configurations" or click the "Config:" heading at the top of the screen NOTE: Making a key global will apply the macro in the currently active configuration to ALL configurations, this essentially means that macros on that key in other configurations will be DELETED. Binding events -------------- Events are an experimental new feature in 0.8.5 and will be fully functional from version 0.9. Currently, events are limited to only a few in-game events but I plan to expand on the available events in the future. Events are bound exactly like binding keys but instead of being triggered by a key press they are triggered when the specified event occurs, for this reason it is necessary to be careful how you use events to ensure that macros don't fire too often. The currently available events in 0.8.5 are as follows: onJoinGame fires when you join a game (both single player and multiplayer) and this is your general-purpose auto-exec. Since macros terminate whenever you leave a game, any long- running tasks have to be started when joining a game. Using EXEC with this event is incredibly powerful. onChat fires when a chat message is added to the display buffer (both received messages and messages added by mods trigger the event), DO NOT UNDER ANY CIRCUMSTANCES USE LOG IN THIS EVENT AS IT WILL CREATE AN INIFINTE LOOP! onHealthChange fires when your health level changes onFoodChange fires when your food level changes onArmourChange fires when your armour level changes onWorldChange fires when changing world but not when changing server (see onJoinGame for that), so useful when changing dimension or world on multiverse-enabled servers onModeChange fires when changing between creative and survival mode onInventorySlotChange fires when the selected inventory slot changes (note that scrolling quickly may "skip" inventory slots and reading the inventory slot variable is recommended to figure out which slot is selected, provides a context variable called OLDINVSLOT which is the last recorded slot before it changed. onOxygenChange fires when your air level changes (this happens between entering water and beginning to drown) onXPChange fires when your XP changes onLevelChange fires when your level changes onItemDurabilityChange fires when the currently held item's durability changes, does not fire for other items in inventory onWeatherChange fires when weather changes from raining to not raining or vice versa Since events may fire often it is recommended to include relatively short macros, and harness conditional expressions to decide when to act on the event. A simple example might be putting the following in the onHealthChange event: $${IIF(HEALTH < 3,"/sethome quicksave")}$$ Using a bukkit plugin which supports multiple homes, this will automatically set a home called "quicksave" once your health reaches 1 heart, allowing you to return to your death point if you subsequently die. Using scripts in your macros: ----------------------------- Scripts are a powerful new addition in 0.5 which allow extra commands to be included in your macros beyond just chat commands. Scripts begin with $${ and end with }$$ A simple script might look like the following: First message|$${wait(5)}$$|Second message This will send the first message, wait for 5 seconds, then send the second message. Currently the list of available script commands is small but I plan to expand scripting support with each release. The current script commands available in 0.5 are as follows: WAIT(time) Waits for the specified number of seconds, alternatively to specify a wait time in milliseconds, add "ms" to the time, for example WAIT(500ms) will wait for half a second. FOV(fov, time) Sets the current FOV to fov, for example FOV(90). If you specify the time parameter the FOV will interpolate in the specified time (seconds). GAMMA(pct, time) Sets the gamma (brightness) to the specified value (percent). If you specify the time option, the gamma will interpolate to the new value. SENSITIVITY(pct, time) Sets the mouse sensitivity to the specified value (percent). If you specify the time option, the gamma will interpolate to the new value. VOLUME(pct, time) Sets the sound volume to the specified value (percent). If you specify the time option, the gamma will interpolate to the new value. MUSIC(pct, time) Sets the music volume to the specified value (percent). If you specify the time option, the gamma will interpolate to the new value. FOG() Takes no parameters and toggles the render distance. GUI(screen) Displays the specified GUI. The available values for "screen" are: chat menu inventory options video controls macrobind macroconfig CONFIG(name) Selects the specified config, specify "" to select the default config or enter a config name. IMPORT(name) Imports the specified config. The config will be overlaid on the current config, replacing only keys which are defined in the imported configuration. For example, if you are using a server config and have a worldedit config which defines only the numpad keys, you can IMPORT the worldedit config and only the numpad keys will be altered, the rest of the keys will remain using the active config. Calling IMPORT again with the same config will UNIMPORT the config (it is a toggle). UNIMPORT() Removes the active overlaid config if one is active. DISCONNECT() Disconnect from the current server, or quit to title if in single player. KEY(key) Simulate pressing the specified key once. The available values for "key" are: inventory drop chat attack use pick If you want to activate a keybind for a different key, you may also use the LWJGL key code for the key bind to activate. To pump actual simulated keypresses into the keyboard buffer, use the TYPE and PRESS commands instead. KEYDOWN(key) Simulates a key down event for the specified key, use the KEYUP command to release the key. Available values for "key" are: forward back left right jump sneak Insert the LWJGL key code to send a key event NOTE: If you wish to send a KEYDOWN followed by a KEYUP you *must* insert a WAIT between the two commands, otherwise Minecraft will not register the key event. For example, use the following script to simulate pressing the forward key for half a second: KEYDOWN(forward);WAIT(500ms);KEYUP(forward) KEYUP(key) Simulates a key up event, the available keys are the same as for the KEYDOWN command. TOGGLEKEY(key) Toggles the key/up down state of the specified key. The available keys are the same as for the KEYUP and KEYDOWN commands. For example to create a simple auto-walk macro, use the following script: TOGGLEKEY(forward) ECHO(message) Echos the specified text into the chat buffer, this is useful in long scripts to avoid having to include multiple }$$ $${ symbols. LOG(message) Echos the specified text to the local chat log. Useful to track running macros. You can include colour codes in the format &0 INVENTORYDOWN(count) Scrolls the specified number of slots through the inventory INVENTORYUP(count) Scrolls the specified number of slots through the inventory PICK(itemid) If an item with the specified ID exists on your hotbar, the item is selected SLOT(number) Select a slot on the hot bar (valid numbers are 1 through 9) SPRINT() Begin sprinting (if the player would normally be able to sprint) UNSPRINT() Stop sprinting STOP(keyname) Terminates active (latent) macros with the specified key name. Use without parameters to stop latent functions on the CURRENT key. Alternatively specify "all" to stop ALL macros, or the name of a macro task started with EXEC (see below). TYPE(string) Pumps the individual keys specified in into the keyboard buffer as if they were typed by the user. This is useful for supplying key events to mod GUIs or other input fields which are not normally scriptable. This function only accepts printable characters, to pump other keys into the buffer use the PRESS command instead. PRESS(key) Pumps a key down followed by a key up event into the keyboard buffer for the specified key, simulating the key being pressed. This should work for mods which sample the keyboard directly rather than using the KeyBind mechanism in Minecraft. Key should be a valid LWJGL key name, eg. PRESS(RETURN); PLACESIGN(line1,line2,line3,line4,showgui) If you have a sign on your hot bar and are aiming at a block within placement distance, the sign will be placed at the 4 lines of text will be set to the text specified. If the fifth option is omitted or false, the sign will be placed immediately. If the fifth option is 1 or true, the sign gui will be displayed with the lines of text pre-populated. eg. PLACESIGN("[Buy]","64","Stone","$5"); For placing signshop signs for bukkit essentials. PLACESIGN("[Buy]","64","Stone","$5",true); Will pre-populate the specified text and allow the sign to be edited. TEXTUREPACK(name) Instantly switches to the texture pack which matches the specified name. If an exact match cannot be found, the first texture pack which matches the specified name will be selected, this means you can select texture packs by only entering a key part of the name like "pangea", "space", "medieval" or "doku" for example. To select the default texture pack, simply execute the command with no parameters: TEXTUREPACK() SET(flag) Sets the specified flag to true (on) for this macro. This is used with conditionals (see below). You can use any name for flags that you wish, but bear in mind that all flags are internally converted to lower case and must be referenced in lower case in conditional statements. UNSET(flag) Like the SET command, but sets the specified flag to false (off) for this macro. TOGGLE(flag) Like SET and UNSET, but changes the state of the flag to the opposite of its current value. If the flag is true (on) it will be set to false (off), and vice versa. INC(counter) Increments a counter by 1, or alternatively specify an amount to increment by, eg. INC(#mycounter, 3) DEC(counter) Decrements a counter by 1, or alternatively specify an amount to decrement by, eg. DEC(#mycounter, 3) EXEC(filename) Executes a file as a script, the script executes as a separate task, allowing you to "spin off" a separate macro which runs concurrently with other macros. Use EXEC(filename,taskname) if you wish to be able to stop the task at a later time using STOP, specifying the taskname allows you to stop the task by specifying the name: EXEC("script.txt","mytask"); ... STOP("mytask"); Following the task name you can also specify a variable number of parameters which will be passed to the target script as both numbered parameters and numbered variables: EXEC("script.txt","mytask","param1","anotherparam"); Will allow you to use the specified parameters in your target script as $$[1] $$[2] $$[3] and so on as parameters or alternatively var1, var2, var3 as variables: IF(var1 = "param1"); // do something ELSE; ECHO("Param 2 is $$[2]"); ENDIF; The difference between parameters and variables is that parameters are replaced into the script *before* it is executed whereas variables are only checked when the script is executed, this allows you to use a parameter like this: $$<$$[1]> to include a file specified at invoke-time. Using variables for other values is "safer" because the variable value is never inserted into the script and therefore cannot corrupt the macro if invalid values are passed in. LOOK(dir,speed) Sets the player's look direction to the specified direction, this can be NORTH, SOUTH, EAST, WEST or NEAR. The NEAR option snaps the view to the nearest cardinal direction to the current view direction. You can also specify the speed to interpolate to the specified direction. The LOOK command also supports the following variations: LOOK(yaw) LOOK(yaw,pitch) LOOK(yaw,pitch,speed) Where yaw and pitch are specified as either absolute values (eg. 180 to face south, or relative values, eg. +45 to turn 45 degrees LOOKS(dir,speed) This is identical to LOOK, but adds a smooth ramp to the interpolation making it more cinematic. You can include multiple commands in your script by separating them with semicolon. Control-Flow Commands in Scripts: --------------------------------- There are two types of control-flow commands available in the current scripting engine: loops and conditionals. Loops take the form of a DO LOOP, a simple loop looks like this: DO(5);ECHO("Message");WAIT(2);LOOP Will echo "Message" 5 times with a 2 second delay. You can also specify DO without parameters to generate an infinite loop: DO;ECHO("MESSAGE");WAIT(300);LOOP Will echo "Message" every 300 seconds forever. Use STOP() or the macro override function to terminate active macros. Conditionals have three forms, a simple IF ENDIF: IF(CTRL);ECHO("Control key is down");ENDIF; an IF ELSE ENDIF form: IF(CTRL);ECHO("Control key is down");ELSE;ECHO("Control key not down");ENDIF; and an IF ELSEIF ELSE ENDIF form: IF(CTRL);ECHO("Ctrl down");ELSEIF(ALT);ECHO("Alt down");ELSE;ECHO("Neither");ENDIF; Conditional statements can also be nested and included in loops. A "conditional echo" statement is also included, IIF which can be used as follows: IIF(condition,"text"); is functionally equivalent to: IF(condition);ECHO("text");ENDIF; and: IIF(condition,"text","text2"); is functionally equivalent to: IF(condition);ECHO("text");ELSE;ECHO("text2");ENDIF; You can also combine conditionals and loops using the DO...WHILE and DO...UNTIL constructs: DO; // stuff to do UNTIL(condition); or DO; // stuff to do WHILE(condition); Conditional operands fall into two categories, GLOBAL variables which are in capitals and are provided by the scripting engine (a list of these is provided below), and LOCAL variables which are true/false flags stored within each macro and are always specified in lower case. Most of the standard boolean operators are supported, such as < > = != >= <= && || and can be used to compare variables to literal strings or numeric values. A simple example might be: IF(HUNGER < 12); LOG("You should eat food to stay healthy"); ENDIF; You can also create more complex expressions using parentheses: IF((HUNGER < 12) && (HEALTH < 10)); LOG("You should REALLY eat some food to stay healthy!!"); ENDIF; Using your own flags is also possible, this allows you to create simple toggles or modifiers: IF(someflag); LOG("The flag is true, setting it to false"); UNSET(someflag); ELSE; LOG("The flag is false, now setting it to true"); SET(someflag); ENDIF; You can also use TOGGLE(flagname) to toggle a flag to the opposite state. As of 0.8.5, the following GLOBAL VARIABLES are available: General variables: KEYID LWJGL key code of the key which triggered this macro. KEYNAME LWJGL key name of the key which triggered the macro. CONFIG Currently active configuration name (see above) - case sensitive. Input variables: CTRL True if the user is holding down the CTRL key now. ALT True if the user is holding down the ALT key now. SHIFT True if the user is holding down the SHIFT key now. KEY_ True if the key with the specified LWJGL key name is down. For example KEY_A or KEY_SPACE. All input variables can be prefixed with ~ to get the state when the macro was invoked, for example use ~CTRL to get the state of the ctrl key when the macro was triggered. World variables: TICKS Current world ticks count (time of minecraft day). SEED Current world seed RAIN Current rain strength from 0 to 100 SERVER Current server address TEXTUREPACK Currently selected texture pack name Player variables: PLAYER Name of the current player - case sensitive. HEALTH Player's current health amount (0 to 20 - each heart is 2 health points). ARMOUR Player's current armour amount (0 to 20 - each icon is 2 armour points). HUNGER Player's current hunger level (0 to 20 - each icon is 2 food points). XP Player's current experience level (in current level). TOTALXP Player's total current experience. LEVEL Player's current level. MODE Player's gamemode - 0 for survival or 1 for creative. INVSLOT Current inventory slot selected (1 to 9) LIGHT Light level at the current location (only valid underground) XPOS Current X coordinate YPOS Current Y coordinate ZPOS Current Z coordinate DIMENSION Current dimension: NETHER, SURFACE, END or UNKNOWN OXYGEN Current air level ITEM Currently wielded item ID DURABILITY Currently wielded item durability Working with flags, counters and global variables ------------------------------------------------- As mentioned above, global variables are always UPPERCASE and user-defined flags and counters are lowercase. Counters are prefixed with # to indicate a counter variable. Normally flags and counters are local in scope and are only available within the context of the macro itself, this allows you to use the same script on multiple keys without having the flags interfere with one another. However sometimes you may wish to access a counter or flag from another macro, to do this you should prefix the flag or counter name with @ For example @flag is a global flag, and @#counter is a global counter. You can also include variable values in LOG and ECHO messages by surrounding them with % signs. This can be helpful when debugging your macros: LOG("Your health is %HEALTH%"); LOG("My counter is equal to %#mycounter%"); LOG("The state of the global flag is %@someflag%"); Advanced Settings ----------------- - Customising the Keyboard Layout The default keyboard layout is a UK keyboard layout although most keys should be correctly positioned for US keyboards as well (with a couple of exceptions). Should you wish to customise the keyboard layout you can enable keyboard layout editing in the settings menu Returning to MACRO BIND mode will now have an additional button "Edit" which will allow keyboard keys to be moved around on the screen. - To delete a key from the display press [DEL]. - To add a key which is not displayed press the key (pressing a key which is already present will highlight the key). When you are finished click the "Edit" button again. - Utilising fallback mode (compatibility mode) Version 0.7 includes a new keyboard input layer designed to improve compatibility with other mods, this is achieved by directly manipulating the LWJGL keyboard buffer. However if this new input layer causes issues, you can use fallback mode to use the old (less versatile) behaviour. To enable fallback mode, choose "Compatible mode" from the options screen and then restart Minecraft. Notices ------- Minecraft and related resources are Copyright Mojang AB. This mod and related resources are Copyright 2011 Adam Mummery-Smith You MAY include this mod in compilation packs or mod collections You MAY redistribute the mod You MAY use this mod or any of the constituent classes as the basis for other mods provided that you credit any of my work to me. You MAY have fun with the mod and make suggestions for new features in the MCF thread. You MAY NOT donate money to me, if you like this mod then please donate to this worthy cause instead: http://www.minecraftforum.net/topic/632211-buying-minecraft-gift-codes-for-others/