DFScript
DFScript 是一款专为 DiamondFire 打造的模组,旨在允许在客户端进行脚本编写。该模组是对已停服的 CodeUtilities 模组的分离与改进版本。
-
你可以从其 Github 页面 或 Modrinth 页面 下载 DFScript。
-
你可以在 问题标签页 报告问题。
-
你可以在此加入我们的 Discord。
关于
DFScript 通过新增的“脚本”功能添加了新功能。脚本是在客户端菜单中构建基于事件代码(类似于 DiamondFire),其中事件和操作均为简单的基于客户端的活动。
例如,一个脚本可以在玩家收到包含其名称的消息时播放声音,或者自动在发送的消息前添加 @ 字符。
要访问脚本菜单,请输入 /scripts,随后将显示一个列出你已安装的所有脚本的菜单。在这里你可以启用、禁用、编辑和上传脚本。
(一个简单的可以通过左上角按钮访问的菜单,用于禁用脚本。)
要安装脚本,你可以点击“Add”并浏览其他用户创建的脚本,或者如果你想自己创建一个,请选择“New Script”。
创建脚本
要创建新脚本,请输入 /script,选择“Add”,然后选择“New Script”。命名你的脚本后,它将被创建并显示在主菜单中。从这里开始,你可以编辑、上传、删除和切换你的脚本。
以下是这些操作各自的作用:
- 编辑:在此菜单中,你可以为脚本添加选项和代码。
上传:上传脚本以便其他拥有此模组的用户可以安装并使用它。(他们无法修改代码)
- 删除:永久删除你的脚本。
- / 切换:开启或关闭你的脚本。当脚本处于关闭状态时,它不会运行任何内容。(红色表示脚本当前处于开启状态,绿色表示脚本处于关闭状态)
要编辑你的脚本,请选择编辑图标,将打开一个新菜单。从这里开始,你可以添加代码、更改脚本描述以及添加配置选项。
- 在此处,你可以为脚本编写简短的描述,以便告知可能使用它的用户任何重要信息。 你也可以添加配置选项,用户无需访问代码即可更改这些选项。这些选项的值可以在你的代码中使用。(更多信息请参见此处)
交互
左键点击
- 用于点击按钮
- 用于向脚本添加代码,以及向代码块添加参数
- 在脚本菜单中使用以编辑代码块的参数
- 用于选中文本框
右键点击
- 在脚本菜单中的代码块上使用以调出一个小菜单,你可以在其中:
- 删除代码块
- 在代码块之前插入代码
- 在代码块之后插入新代码
- 也可用于点击按钮
Escape (退出)
- 在任何菜单中使用以返回上一级菜单
滚动
- 上下移动菜单
编辑脚本
请注意,只有你自己制作的脚本才能编辑代码。任何下载的脚本仍然可以删除、切换和更改其选项,但代码将不可访问。
选择“Add”按钮以向脚本添加代码。从那里你可以选择类别,以及特定的代码块。如果你悬停在它们上方,每个代码块都会有简短的描述,以帮助你理解它们的作用。
所有代码都设置在一个菜单中。就像在 DiamondFire 中一样,所有代码必须以事件开头。当触发该事件时,其中的代码将从上到下依次运行。
更改参数
大多数代码块需要内部参数才能正确执行。你可以通过在脚本菜单中悬停在代码块图标上来查看该代码块所需的参数。参数后的星号表示该参数的值不是必需的,代码块可以在没有该值的情况下运行。
要为这些参数添加值,左键单击你想要编辑的代码块,将弹出一个菜单。代码块中已有的参数将会显示。要添加值,请点击“Add”按钮,将出现一个带有文本输入框的新菜单。
此输入屏幕有两个重要部分。
- 文本框。在这里你可以输入数字、字符串、变量名或任何其他类型的所需值。在选择类型之前,请确保已完成你想要添加到代码块中的值。
- 值类型。在这里你可以选择要向代码块添加的值类型。例如,如果我想添加一个名为“score”的变量,我会在文本框中输入
score,然后点击变量图标(岩浆膏)。一个名为“score”的变量将被添加到代码块中。 大多数值类型及其图标,如文本、数字和变量,你可能在 DiamondFire 中已经认识,但这里有一些你可能不太熟悉的:
- 客户端值:(无需输入文本。) 选择此值将弹出一个包含与客户端相关值的菜单,其结构与 DiamondFire 的游戏值非常相似。
其中一些值可以在任何场景中使用,例如玩家选中快捷栏槽位的编号或主手物品。
另一些值则只能在特定事件下的代码中使用,例如最后接收到的消息 (与 'OnRecieveChat' 事件配对) 或最后接收到的声音 (与 'OnRecieveSound' 事件配对)。
- 配置值:(无需输入文本。) 选择此值将显示你添加到脚本中的所有配置选项菜单。这些选项将作为变量并返回相应选项的值。
例如,如果我将“选项 1”创建为字符串类型,且用户将其设置为
complete,那么“选项 1”的配置值将以字符串形式返回 'complete'。 这些值可以是几乎任何类型,因此请注意确保你所使用的代码块支持该值类型。
- 配置值:(无需输入文本。) 选择此值将显示你添加到脚本中的所有配置选项菜单。这些选项将作为变量并返回相应选项的值。
例如,如果我将“选项 1”创建为字符串类型,且用户将其设置为
目前不支持更改已添加参数的顺序和内容,因此如果你犯了错误,必须删除并重新设置。
禁用脚本 - !!
有时在创建脚本时,你可能会意外导致你的客户端执行违反 DiamondFire 规则的操作,例如让你的客户端刷屏或其他类似行为。如果是这种情况,请立即离开服务器。在你的多人游戏屏幕左上角,会有一个按钮 (),点击它将打开一个可以禁用脚本的脚本菜单版本。当你重新加入服务器时,该脚本将被禁用。你可以在禁用的脚本中编辑代码,因此请确保在重新启用脚本之前已修复问题。
如果问题是由非你制作的脚本引起的,请在 discord 中举报该脚本以便将其移除。
下载脚本
要下载其他人制作的脚本,请打开主脚本菜单,选择“添加”,这里将列出其他作者制作的脚本以及一个搜索栏。名称旁边带有星号的脚本表示它们经过验证且安全可用。
!! 未经验证的脚本可能存在潜在危险,虽然不会危害你的电脑,但它们可能导致你的客户端刷屏或在 DiamondFire 上执行其他不受欢迎的活动。如果你对某个特定脚本不确定,可以在 discord 中询问。!!
从此处选择一个脚本将弹出一个显示脚本信息的菜单,包括作者姓名、脚本 ID 以及是否已通过审核。 点击此处安装按钮会将脚本添加到你的客户端。聊天框中将显示一条消息以验证脚本已加载。此下载的脚本将出现在正常的脚本菜单中,只是不具备上传或编辑其代码的功能。
命令和文件
所有 DFScript 命令均以 /scripts 开头。
/scripts打开主脚本菜单。/scripts recursion (number)更改单个 tick 中可以触发的事件数量。/scripts reload重载你机器上所有的脚本。如果你通过文件手动安装或更改脚本,请使用此命令。/scripts vars (script name)列出选定脚本中所有变量的值。类似于 DiamondFire 的 /p vars 命令。
要访问脚本文件,请在你的机器上进入 %appdata%\.minecraft\DFScript。这里将有一个“Scripts”文件夹,其中包含以 json 文件格式安装的所有脚本。如果一个脚本管理着文本文件,它们将位于名为 scriptname.json-files 的子文件夹中。
你可以通过复制粘贴 json 文件到另一个位置来轻松备份脚本。在此文件夹中粘贴或删除 json 文件将在游戏中产生相同的效果,因此请谨慎操作。
DFScript
DFScript is a mod created for DiamondFire to allow scripting on the client. This mod is a seperation and improvement from the shutdown mod CodeUtilities.
-
You can download DFScript from its Github page, or its Modrinth page.
-
You can report issues on the issues tab
-
You can join our discord here
About
DFScript adds the ability to add new features through the added 'scripting' ability. Scripting is constructing event based code (similar to DiamondFire) inside a client side menu, with the events and actions being simple client-based activities.
For example, a script could play a sound when the player receives a message with their name in it, or automatically add the @ character in front of sent messages.
To access the scripting menu, run /scripts, and a menu will appear showing all of the scripts you have installed. Here you can toggle, delete, edit and upload scripts.
(A simple menu which can disable scripts can be accessed through the button in the top left.)
To install a script you can click 'Add' and browse through scripts that others have created, or select 'New Script' if you would like to create one yourself.
Creating Scripts
To create a new script, run /script, select 'Add', and 'New Script'. After naming your script, it will be created and displayed in the main menu. From here, you can edit, upload, delete, and toggle your script.
Here is what each of these actions do:
- Edit: From this menu, you can add options and code to your script.
Upload: Uploads the script so that others with the mod can install and use it. (They can not modify the code)
- Delete: Deletes your script permanently.
- / Toggle: Toggles your script on and off. When a script is off, it does not run at all. (Red means script is currently on, green means script is off)
To edit your script, select the edit icon and a new menu will be opened. From here, you can add code, change your scripts description and add config options.
- From here you can write a short description about your script to tell others who may use it any important information. You can also add config options which users can change without accessing the code. The values of these options can be used in your code. (More info later)
Interactions
Left click
- Use on buttons to click them
- Use to add code to your script, and to add parameters to code blocks
- Use in your script menu to edit parameters of a code block
- Use to select text box
Right Click
- Use on code blocks in your script menu to bring up a small menu where you can:
- Delete the code block
- Insert code before the code block
- Insert new code after the code block
- Can also be used on buttons to click them
Escape
- Use in any menu to go back to the previous menu
Scroll
- Moves a menu up and down
Editing Scripts
Note that it is only possible to edit code in a script you have made yourself. Any downloaded script will still be able to be deleted, toggled, and have its options changed, but the code will be inaccessible.
Select the 'Add' button to add code to your script. From there you can select the category, and a specific code block. There is a short description about each block if you hover over them to help you understand what they do.
All code is set in one menu. Just like in DiamondFire, all code must start with an event. When that event is triggered, the code inside it will run from top to bottom.
Changing Parameters
Most code blocks need parameters inside them so they can execute properly. You can view what parameters a code blocks needs by hovering over its icon in your script menu. An asterisk after a parameter means that a value for it is not required and the code block can run without it.
To add values for these parameters, left click on the code block you would like to edit and a menu will be brought up. Any parameters already in the code block will show. To add values, click the 'Add' button, and a new menu with a text input box will appear.
This input screen has two important sections.
-
The text box. Here is where you input a number, string, name of a variable or any other type of value required. Make sure you have finished the value you would like to add to your code block before selecting a type.
-
The value type. Here is where you select what type of value you would like to add to your code block. For example, if I wanted to add a variable called 'score', I would type
scorein the text box, then click on the variable icon (magma cream). A variable named 'score' will be added to the code block. Most value types and their icons such as a text, a number and a variable you may recognise from DiamondFire, but here are some ones you may not be familiar with:- Client Value: (Requires no text input.) Selecting this value will bring up a menu containing values related to the client, very similar to DiamondFire's game values. Some of these can be used in any scenario, such as the number of the players selected hotbar slot, or the players main hand item. Others can only used if the code is under a certain event, such as the last received message (pairs with the 'OnRecieveChat' event) or the last received sound (pairs with the 'OnRecieveSound' event).
- Config Value: (Requires no text input.) Selecting this value will bring up a menu of all the config options you have added to your script. These will act as a variable and return a value of the option.
For example, if I had created Option 1 as a string, and the user had set it to
complete, the config value for options 1 would return 'complete' as a string. These can be nearly any value type, so pay attention to make sure the code block you are using supports the value type.
Currently, changing the order and contents of added parameters is not supported, so you will have to delete and redo if you make a mistake.
Disabling Scripts - !!
Sometimes when you are creating a script, you may accidentally make your client complete actions which are against DiamondFire rules, such as making your client spam, or other similar actions. If this is the case, immediately leave the server. In the top left if your multiplayer screen, there will be a button button () which will open up a version of the scripts menu where scripts can be disabled. When you rejoin the server the script will now be disabled. You can edit code inside a disabled script, so make sure you have fixed the issue before re-enabling the script.
If the issue came from a script you did not make, report the script in the discord so it can be removed.
Downloading Scripts
To download a script that someone else has made, open the main scripts menu, select add, and there will be a list of scripts others have made as well as a search bar. Scripts with a star next to their name mean that they are verified and safe to use.
!! Unverified scripts may potentially be dangerous, not towards your computer, but they may make your client spam or do other activities not appreciated on DiamondFire. You can ask in the discord if you are unsure about a certain script. !!
Selecting a script from here will bring up a menu showing information about the script such as the authors name, script ID, and if it has been approved or not. Clicking the install button from here will add the script to your client. A message will be shown in chat verifying the script has been loaded. This downloaded script will appear in the normal scripts menu, just without the ability to upload it or edit its code.
Commands and Files
All DFScript commands begin with /scripts.
/scriptsOpens the main script menu./scripts recursion (number)Changes the number of events that can trigger in a single tick./scripts reloadReloads all of the scripts on your machine. Use this is you are manually installing are changing scripts through files./scripts vars (script name)Lists the values of all the variables in the selected script. Similar to DiamondFire's /p vars command.
To access script files go to %appdata%\.minecraft\DFScript on your machine. Here there will be a 'Scripts' folder, which contains all the scripts you have installed in the form of a json file. If a script manages text files, they will be in a sub folder called scriptname.json-files.
You can easily back up scripts here by copy and pasting the json file into another location. Pasting and deleting json files from this folder will do the same in-game, so be careful about what you change.
下载 DFScript
下载 DFScript
下载 DFScript
下载 DFScript
下载 DFScript
下载 DFScript
下载 DFScript
下载 DFScript
下载 DFScript
下载 DFScript
- 修复了使用 WriteFile 操作将字典写入文件时导致的崩溃问题
- 修复了添加部分和标题时滚动量未保留的问题
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
添加区块认领和玩家组队功能,并与 Xaero's Minimap 和 World Map 集成
模组
添加全屏世界地图,显示你在世界中已探索的区域。与 Xaero's Minimap 搭配使用效果极佳。
评论 0
登录后参与评分
还没有评论,来抢沙发吧