Skip to content

Math Function v2.8

Choose a tag to compare

@aiLinMc aiLinMc released this 09 Jul 13:11

【中文更新日志】

2.8 版本更新 - 自定义函数系统:

  • 新增自定义函数功能!现在你可以使用 /customfunction 命令创建、存储和调用自己的数学函数,让复杂的表达式复用变得轻而易举。
  • 添加自定义函数:/customfunction add <函数名> <表达式> — 例如 /customfunction add square x^2,之后就可以直接使用 square(3) 来计算 9!
  • 查看已定义的函数:/customfunction list 列出所有已保存的自定义函数。
  • 获取函数表达式:/customfunction get <函数名> 查看某个函数的定义。
  • 计算函数值:/customfunction eval <函数名> <x值> 快速计算函数在指定 x 处的值。
  • 修改已有函数:/customfunction modify <函数名> <新表达式> 更新函数定义。
  • 删除函数:/customfunction remove <函数名> 移除不再需要的函数。
  • 一键清空所有自定义函数:/customfunction remove-all(需要管理员权限)。
  • 自定义函数支持相互引用和嵌套调用,例如可以定义 f1(x)=x^2g(x)=sin(f1(x))
  • 自定义函数会自动保存在 custom_functions.json 文件中,重启游戏后依然保留。
  • 自定义函数名称不能与内置函数(如 sinsqrtlog 等)或数学常数(epi)冲突,确保安全。同时 f 作为保留名称也不可用,以避免与 f(x)= 前缀冲突。
  • 所有自定义函数均可在 /fx 命令和函数附魔轨迹命名中使用,极大简化复杂表达式的输入。

【English Changelog】

Version 2.8 - Custom function system:

  • Added custom function support! Now you can use the /customfunction command to create, store, and call your own math functions, making complex expression reuse effortless.
  • Add a custom function: /customfunction add <name> <expression> — e.g. /customfunction add square x^2, then use square(3) to compute 9!
  • List all defined functions: /customfunction list shows all saved custom functions.
  • Get a function expression: /customfunction get <name> displays the definition of a function.
  • Evaluate a function: /customfunction eval <name> <x_value> quickly computes the function value at a given x.
  • Modify an existing function: /customfunction modify <name> <new_expression> updates the function definition.
  • Remove a function: /customfunction remove <name> deletes an unwanted function.
  • Clear all custom functions at once: /customfunction remove-all (requires operator permissions).
  • Custom functions support mutual references and nested calls, e.g. define f1(x)=x^2 and g(x)=sin(f1(x)).
  • Custom functions are automatically saved to custom_functions.json and persist across game restarts.
  • Custom function names cannot conflict with built-in functions (such as sin, sqrt, log, etc.) or math constants (e, pi), ensuring safety. The name f is also reserved to avoid conflicts with the f(x)= prefix.
  • All custom functions can be used in /fx commands and function enchantment trajectory naming, greatly simplifying the input of complex expressions.