本帖最后由 Rain_Effect 于 2018-6-11 17:57 编辑



本教程仍在编辑中!
目前更新至章节一:操作界面介绍及初步运用

编辑时帖子会进入审核状态,请稍等其恢复,不便之处敬请谅解

> MOD简介 <

      Macro/Keybind Mod的作用正如其名,是一个和宏与按键相关的mod。你可以通过这个模组,自定义键盘上按键的功能,如绑定指令运行脚本等。同时该模组也内置了自定义GUI的功能。如果合理使用的话,可以说不论搭配何种模组,都可以作为一个强力的辅助工具,即便是在服务器内。该模组从一些简单的操作,如一键回城玩家传送等简单的事情,到自动合成/种地,这个模组都可以替你完成。当你仅仅是想要自动化一件很简单的事情/编写一些简单的脚本,却找不到合适的工具的时候,那么,你可以试试这个模组。在试过之后,你会发现,动脑筋解决问题也是一件很有趣的事情。

> 我的话 <

      这个模组说真的,并不新奇,相反它其实在11年的时候就发布了,并在MCBBS中被很多用户搬运过很长的一段时间了,但是苦恼于配置的复杂/调整的繁琐,没有多少关于这个模组关键内容的更多教程,在这里我会给大家一一进行讲解和教学,各位可以期待一下,自己究竟通过这个模组,可以做到什么自己曾经做不到的?
站内搬运帖:
[1.12.X-1.3.2][Macro/Keybind Mod] 用来在游戏里写脚本的Mod--内含简单教程 - 搬运者: yhr
站外原帖:
MinecraftForum地址 LiteLoader PlanetMinecraft
历史帖子


> 请注意 <

本教程基于1.12.1版本下的Macro/Keybind Mod 0.15.4进行
各版本之间,部分参数会有不同的变动

如需将游戏内模组语言修改为中文,请看附录① Q&A提问区

本教程使用sm.ms图床


> 支持我 <

如果你支持我,以及我的教程,请给我评分点个人气,送个金粒!
要记得,评分是不会扣除自身人气的,但金粒会。
当然,有一定经济能力的,如果还能捐赠我喝杯咖啡,我会非常感谢的。



章节一  操作界面介绍及初步运用
> 操作/界面介绍 <


      初次启动模组时,游戏会提醒你安装成功,并建议你打开"控制"去进一步了解该模组的操作按键。(如图一)

      进入"控制"后,Macro模组的所有按键会默认置于最底(旧版本Macro为置顶),其中:
  • "Macro activate" 为激活键,默认为"Grave"(即"Esc"键下方第一个按键),用于打开宏激活菜单,可避免和控制内按键的冲突的情况下,启动当前按键下所设定的宏;
  • "Macro console" 为控制台,默认关闭(启用时默认为"Grave"键),可用于进行代码测试等操作,也是用户在制作这个脚本时经常使用到的一个功能;
  • "Macro override" 为防冲突按键,默认为冲刺键(即"左Ctrl"),可在被绑定宏的按键与其他按键冲突的时候,提前按住防冲键可在启动宏的情况下不会触发原按键的功能
    (例如G键我们绑定了合成表,而在该模组中我们对G键定义了发送"/menu"命令的宏,直接点击G键只能开启合成表,但如果在按G键之前,长按防冲键,会启用G键上的宏而不会打开合成表);
  • "Settings key combo" 为设置组合键,实际功能为宏定义菜单键,可使用该组合按键打开宏定义菜单,进行对按键/事件/界面等的宏定义。


      在游戏中,使用宏定义键,打开宏定义菜单,左上角为菜单按钮,紧接着中上方为宏定义界面切换,右上角为目前使用的配置方案,左下角为操作按钮,中下为操作提示栏,右下为多样化设置按钮,而在其中间的一大片则为各个宏定义方案的功能界面。而在宏定义菜单中,细分了宏定义三界面:"按键Keys"(图二<1>)、"事件Events"(图二<2>)、以及"界面Buttons(翻译下为按钮)"(图二<3>)


      使用控制台键(需启用后才能操作),可打开控制台菜单(图三),初次测试命令以及测试编写脚本均可在这里进行。


帖子正在编辑中。。。


初步运用① 按键宏定义
> 了解按键宏定义并进行初步运用 <

      初

帖子正在编辑中。。。


附录① Q&A提问区
Q1: 如何安装模组?
A: 模组需要LiteLoader的前置才能使用,可以于LiteLoader官网下载对应版本的安装器,并安装于拥有原版本核心的客户端内。当然你也可以使用HMCL进行直接下载,选择liteloader版本后,他会自动为你安装好所需的前置。
模组需要从官网下载,如果你无法翻墙的情况下可以到站内的搬运帖内进行下载:
[1.12.X-1.3.2][Macro/Keybind Mod] 用来在游戏里写脚本的Mod--内含简单教程 - 搬运者: yhr

Q2: 模组无自带中文该怎么办?
A: 模组本身无自带中文,的确是一个很恼人的痛,因为不是所有人都是英语十级,当然,其实也有解决办法的!这里我会附上一份汉化压缩包,使用压缩工具(例如winrar)打开macro的litemod文件,将相对应的汉化压缩包内的文件直接拖拽到模组内,在游戏内只要你的语言为“简体中文(中国)”就可以直接使用到模组的汉化内容。
支持1.7-1.10版本的汉化压缩包: macro汉化 for 1.7-1.10.rar (18.27 KB, 下载次数: 9)
支持1.11-1.12版本的汉化压缩包: macro汉化 for 1.11-1.12.rar (18.27 KB, 下载次数: 29)


如果有更多希望提问的问题,又或者在教程中发现什么错误,请在帖子内进行回复,我会统一回复的,谢谢。


附录② 参数列表


所有脚本列表
更新到1.12.1


脚本语法返回数据
脚本简述初次出现版本


游戏脚本
CLEARCRAFTING()none
Clears the auto-crafting queue


CRAFT(<item[:damage]>,[amount],[throw],[verbose])none
Queues an auto-crafting request


CRAFTANDWAIT(<item[:id]>,[amount],[throw],[verbose])
Queues an auto-crafting request and waits for it to complete


DISCONNECT()
Disconnects from the current game or server


GETID(<x>,<y>,<z>,<#idvar>,[#datavar])ID of the block at the specified position
Gets the ID and optionally the data value of the block at the specified coordinates in the world


GETIDREL(<xoffset>,<yoffset>,<zoffset>,<#idvar>,[#datavar])ID of the block at the specified position
Gets the ID and optionally the data value of the block at the specified coordinates relative to the player


GETITEMINFO(<item[:damage]>,[<&namevar>],[#maxstacksize],[&type],[#dropid])Name of the item
Gets the name and other info for the specified item id, returns "None" if the item is not valid


GETSLOT(<item[:damage]>,<#idvar>,[startfromslotid])Slot ID containing a matching item
Gets the id of the slot containing an item matching the specified item id, returns -1 if item not found


GETSLOTITEM(<slotid>,<#idvar>,[#stacksizevar],[#datavar])Item ID of the item in the slot
Gets information about the item in the specified slot


INVENTORYDOWN([amount])
Scrolls the specified number of slots down through the hotbar


INVENTORYUP([amount])
Scrolls the specified number of slots up through the hotbar


ITEMID(<item>)Legacy ID for the item
Gets the legacy (numeric) ID for the specified item


ITEMNAME(<id>)Item descriptor for the specified item id
Get the item descriptor for a legacy (numeric) item ID


LOOK(<yaw>,[pitch],[time])
Faces the player in the specified direction, prefix angles with + or - for relative moves


LOOKS(<yaw>,[pitch],[time])
Smoothly turnes the player to the specified direction, prefix angles with + or - for relative moves


PICK(<item[:damage]>,[item[:damage]],...)Item ID of the item which was picked or -1 if not picked
Selects the specified item id if it is on the hotbar, specify multiple items to pick in order of preference


PLACESIGN([line1],[line2],[line3],[line4],[showgui])
Places a sign in the world with the specified text (if you have one)


PLAYSOUND(<sound>)
Plays a sound


RESPAWN()
Respawns the player if you are dead


SETSLOTITEM([item[:damage]],[slot],[amount])
Creative mode only, set the contents of a hot bar slot


SLOT(<slot>)
Selects the specified slot on the hot bar


SLOTCLICK(<slot>,[button],[shift])
Simulates clicking on the specified slot in the current GUI, optionally using RMB and shiftkey


SPRINT()
Sets the player state to sprinting if sufficient stamina (food)


TILEID(<item>)Legacy ID for the tile
Gets the legacy (numeric) ID for the specified tile


TILENAME(<id>)Tile descriptor for the specified tile id
Get the descriptor for a legacy (numeric) tile ID


TRACE(<distance>,[entities])Ray trace result type
Performs a ray trace operation which sets the raytrace variables in the local scope. Distance can be 3-256.


UNSPRINT()
Sets the player state to not sprinting


输入脚本
KEY(<bind>)
Activates the specified key binding for 1 tick


KEYDOWN(<bind>)
Sets the specified key binding state to pressed, only works with pressable bindings


KEYUP(<bind>)
Sets the specified key binding state to unpressed, only works with pressable bindings


TOGGLEKEY(<bind>)
Toggles the pressed state of the specified key binding, only works with pressable bindings


PRESS(<lwjgl_name>)
Injects the specified key event directly into the keyboard buffer for 1 tick


TYPE(<text>)
Injects the specified key sequence directly into the keyboard buffer at a rate of 1 key per tick


语言脚本
<var> = <value>
Internal function


BREAK
Interrupts exection of the innermost loop


CALCYAWTO(<xpos>,<zpos>,[#yaw],[#distance])Yaw value to coordinates
Calculates the absolute yaw angle to the specified coordinates


DEC(<#var>,[amount])
Decrements the specified counter by 1 or by the specified amount


DECODE(<input>,[&output])Decoded string
base64_decode


DO([count])
Begins a loop, specify a number of loops to limit the loop count


ECHO(<text>)
Sends the specified message as a chat packet


ENCODE(<input>,[&output])Encoded string
base64_encode


ELSE
ELSE clause


ELSEIF(<condition>)
ELSEIF clause


ENDIF
ENDIF clause


ENDUNSAFE
Ends an active UNSAFE block


EXEC(<file.txt>,[taskname],[params],...)
Creates a task by running the specified script file


FOR(<#var>,<start>,<end>,[step])
Begins a FOR->NEXT loop using the specified var as a loop counter, #var can be used inside the loop


FOREACH(<iterator>)
Runs a loop over the specified iterator


GETPROPERTY(<control>,<property>)
Returns the value of the specified property from the specified GUI control


IF(<condition>)
IF clause


IFBEGINSWITH(<haystack>,<needle>)
IFBEGINSWITH clause


IFCONTAINS(<haystack>,<needle>)
IFCONTAINS clause


IFENDSWITH(<haystack>,<needle>)
IFENDSWITH clause


IFMATCHES(<subject>,<pattern>,[&target],[group])
IFMATCHES clause


IIF(<condition>,<truetext>,[falsetext])
Inline IF statement, sends truetext as a chat message if condition succeeds, or sends falsetext if not


INC(<#var>,[amount])
Increments the specified counter by 1 or by the specified amount


ISRUNNING(<macro>)True if the macro is running
Returns whether the specified macro is currently running


JOIN(<glue>,<arrayname>,[&output])Joined array parts
Implodes the specified array to a delimited string


LCASE(<input>,[&output])Input as lowercase
Converts the input string to lower case and stores it in output


LOG(<text>)
Outputs the specified text into the local chat stream


LOGRAW(<json>)
Similar to minecraft tellraw command, parses and outputs JSON chat into local chat stream


LOGTO(<target>,<text>)
Outputs the specified text into the specified target, target can be a text file name or the name of a textarea


LOOP
Ends a loop that was started with DO


MATCH(<subject>,<pattern>,[&target],[group],[default])The matched subpatterns
Runs a regular expression match on the subject and puts the result in &target


NEXT
Completes a FOR->NEXT loop


PROMPT(<&target>,<paramstring>,[prompt],[override],[default])The supplied value
Displays a prompt (or prompts) by parsing the params in paramstring


RANDOM(<#target>,[max],[min])Random value
Assigns a random number between min and max to target


REPLACE(<&subject>,<search>,[replace])Candidate with replaced values, does not alter source string if returned
Replace all occurrences of search with replace in &subject


REGEXREPLACE(<&subject>,<search>,[replace])Candidate with replaced values, does not alter source string if returned
Replace all occurrences of search regex with replace in &subject


SET(<target>,[value])
Sets the value of target to value (or TRUE if value is omitted)


SETLABEL(<labelname>,<text>,[binding])
Sets the text (and optionally binding) of the specified label


SETPROPERTY(<control>,<property>,<value>)
Sets the value of the specified property on the specified GUI control


SPLIT(<delimiter>,<source>,[output])Array containing the split parts
Explode the supplied source string to an array


SQRT(<value>,[#outvar])The square root as an integer
Calculate the square root of value and store it in #outvar


STOP([id])
Stops the current macro, or macros matching the specified ID


STRIP(<&target>,<text>)Stripped text
Strips all formatting codes from the specified text and assigns the result to &target


TOGGLE([flag])
Toggles the specified boolean flag's value


UCASE(<input>,[&output])Input as uppercase
Converts the input string to upper case and stores it in output


UNSAFE(<ticks>)
Begins an UNSAFE block with execution limit set to ticks


UNSET(<flag>)
Un-sets the specified variable


UNTIL(<condition>)
Completes a loop started with DO but exits the loop if condition is met


WAIT(<time>)
Pauses the script for the time specified, suffix "ms" for a wait in milliseconds or "t" to wait in ticks


WHILE(<condition>)
Completes a loop started with DO but exits the loop if condition is not met


ARRAYSIZE(<array>,[<outvar>])Size of the array
Stores the size of the specified array in outvar


INDEXOF(<array>,<outvar>,<searchfor>)Index of searchfor
Gets the first index of searchfor in array and stores it in outvar, returns -1 on failure


POP(<array>,<outvar>)
Removes the last entry from the tail of array and stores it in outvar


PUSH(<array>,<value>)
Appends value to the end of array


PUT(<array>,<value>)
Inserts value at the first empty point in array


模组脚本
CONFIG(<configname>)
Switch to the specified configuration


IMPORT(<configname>)
Overlay the specified configuration


UNIMPORT()
Remove the specified configuration overlay if active


设置脚本
BIND(<bind>,<keycode>)
Set the specified key binding to the specified key code


CAMERA([mode])
Set the current camera mode, call with no arguments to toggle modes


CHATHEIGHT(<value>,[time])
Set height of the Minecraft chat whilst ingame 20-180


CHATHEIGHTFOCUSED(<value>,[time])
Set height of the Minecraft chat whilst in the chat GUI 20-180


CHATOPACITY(<value>,[time])
Set opacity of the Minecraft chat 0-100


CHATSCALE(<value>,[time])
Set scale of the Minecraft chat 0-100


CHATVISIBLE(<value>)
Set visibility of minecraft chat


CHATWIDTH(<value>,[time])
Set width of the Minecraft chat 40-320


FOG([value])
Toggles render distance, or optionally specify render distance


FOV(<value>,[time])
Sets the FOV angle in degrees, specifying time causes the value to change smoothly


GAMMA(<value>,[time])
Sets the brightness value (percent), specifying time causes the value to change smoothly


MUSIC(<value>,[time])
Sets the music volume, specifying time causes the value to change smoothly


RELOADRESOURCES
Reloads resource packs, same as pressing F3 + T


RESOURCEPACKS([pattern],[pattern...])
Sets the resource pack stack to the order matching the specified patterns


SENSITIVITY(<value>,[time])
Sets the mouse sensitivity (between 0 and 200), specifying time causes the value to change smoothly


SHADERGROUP([path])
Sets the active shader group to the shader matching path, use "+" to select next group


SETRES(<width>,<height>)
Sets the size of the minecraft game window


VOLUME(<value>,[time])
Sets the sound volume, specifying time causes the value to change smoothly


杂项脚本
ACHIEVEMENTGET(<text>,[itemid[:damage]])
Displays an "advancement toast" popup with a custom message


BINDGUI(<slot>,<screen>)
Binds the specified custom screen to the slot specified


CLEARCHAT()
Clears the current chat stream


GUI([name])
Show (or hide) a gui screen


POPUPMESSAGE(<message>,[animate])
Display a message in the action bar area


REPL
Access the REPL interface (experimental)


SHOWGUI(<screen>,[esc_screen])
Show a custom gui screen


STORE(<type>,[name])
Store a value into a list using the current environment


STOREOVER(<type>,[name])
Store a value into a list using the current environment and overwrite it if exists


TIME(<[&target>],[format])Time as a string
Stores the current time and date into &target, optionally using format specified


TITLE([title],[subtitle],[inticks],[showticks],[outticks])
Displays the specified custom title, call with no arguments to hide current titles


TOAST(<type>,<icon>,<text1>,<text2>,[ticks])
Displays a custom "toast" popup


事件脚本
CHATFILTER(<enabled>)
Enable or disable the chat filter


FILTER
Indicate that this chat meesage should be filtered and terminate


MODIFY(<newmessage>)
Set new content for this chat message


PASS
Indicate that this chat meesage should PASS the filter and terminate






[groupid=1181]Unknown Domain[/groupid]