Wizards of Lua 是一款适用于 Fabric 和 NeoForge 的服务端模组,允许你在 Lua 中编写法术并在 Minecraft 中施放。无需 Java 或模组开发经验,无需重启服务器,也无需安装客户端模组。
在聊天栏中输入一行命令即可即时改变某些内容:
/lua spell:move("down"); spell.block = Block("gold_block")
将你脚下的方块变为金块。
或者启动一个长期运行的法术,使其响应世界中发生的各种事件:
/lua require "midas"
启动位于 config/wizards-of-lua/midas.lua 的法术,该法术会将玩家击中的任何方块变为金块:
local queue = spell:collect("PlayerAttackBlockEvent")
while true do
local event = queue:next()
spell.pos = event.pos
spell.block = Block("gold_block")
end
浏览 [Examples]( Wizards of Lua.net/examples/) 以了解使用几行 Lua 代码还能构建什么其他功能。
快速上手
快速入门视频(Quickstart Video)将在两分钟内引导你完成模组的安装并施放你的第一个法术。Getting Started Guide 提供了相同的文字版指南,并在此基础上进一步展开。
你能做什么
- 在游戏中运行 Lua: 使用
/lua 命令施放法术,可以是内联代码,也可以是 config/wizards-of-lua 目录下的文件。编辑后的文件在下次使用时会自动重新编译,因此无需重启服务器。
- 改变世界: 放置方块、召唤生物、编辑物品和实体,全部通过丰富的 Lua API 实现。
- 给生物下达指令: 让任何生物移动到指定位置、跟随或逃离某人、站岗或攻击目标。指令仅借用生物的注意力:完成后,生物会恢复其原本的行为。
- 与机器人互动: 生成像真实玩家一样加入的机器人玩家,并由法术控制它们:它们可以行走、战斗、挖掘、建造和聊天,让你可以独自测试小游戏或有同伴相伴。
- 响应事件: 当玩家加入、破坏方块或使用工具时做出反应,并取消或延长后续发生的事件。
- 添加自定义命令: 在运行时注册 Brigadier 命令,支持类型化参数和自动补全。
- 带自动补全的代码编写: 在 Visual Studio Code 中编写法术,获得完整的类型支持。
- 保持控制权: 法术按每刻预算运行并自动让步,因此繁忙的法术不会冻结你的服务器。访问权限由权限级别和节点控制,兼容 LuckPerms。使用
/wol spell list all 查看正在运行的法术,使用 /wol spell break all 停止它们。
- 仅需在服务端安装: 支持单人游戏和多人游戏。玩家无需安装任何内容。
人们构建的内容
- 安全区,其中禁用了 PvP
- 能攀爬梯子的矿车
- 用闪电打击敌对生物的 魔法法杖
- 始终在你身边并攻击伤害你的人的 蜘蛛保镖
- 猪灵守卫,它们在驻守点抵御敌对生物而不会追得太远
- 侍从,一个跟随你的机器人玩家,在你的盾牌后方与你并肩作战,并在你指示时占据指定位置
- 猪灵矿工,它挖掘隧道、用火把照明,并在镐子损坏时从箱子中取出新的镐子
- 伐木法术,当玩家破坏任意一根原木时使整棵树倒下
- 魔法锄头,只需挥动一次即可收割整个麦田
- 类似 Journey 的小游戏
版本说明
版本号遵循 MAJOR.MINOR.PATCH-MCVERSION 格式,例如 8.0.0-1.21.11。第一部分遵循 Semantic Versioning,描述与你脚本的兼容性。- 之后的部分是 Minecraft 的版本号。
提升 MINOR 或 PATCH 版本的更新是安全的。如果 MAJOR 增加,请先查看更新日志,因为你的脚本可能需要进行更改。
了解更多
本模组是原始 Forge 版 Wizards of Lua 针对 Fabric 和 NeoForge 的重写版本,原版已不再维护。两者的 API 不同,为 Forge 版本编写的脚本无法直接运行。
新手?观看快速入门视频,然后在 wizards-of-lua.net 查找指南、示例和完整的 API 参考。
Wizards of Lua is a server-side mod for Fabric and NeoForge that lets you write spells in Lua and cast them inside Minecraft. No Java or modding experience needed, no server restarts, no client mods.
Type a one-liner in the chat to change something on the spot:
/lua spell:move("down"); spell.block = Block("gold_block")
Turns the block at your feet into gold.
Or start a long-running spell that reacts to everything happening in your world:
/lua require "midas"
Starts the spell in config/wizards-of-lua/midas.lua which turns every block a player hits into gold:
local queue = spell:collect("PlayerAttackBlockEvent")
while true do
local event = queue:next()
spell.pos = event.pos
spell.block = Block("gold_block")
end
Browse the Examples to see what else you can build with a few lines of Lua.
Get Started
The Quickstart Video walks you through installing the mod and casting your first spell in under two minutes. The Getting Started Guide covers the same ground in writing, and goes on from there.
What You Can Do
- Run Lua in-game: Cast spells with the
/lua command, either as inline code or from files in config/wizards-of-lua. Edited files are recompiled the next time they're used, so no server restart is needed.
- Change the world: Place blocks, summon mobs, edit items and entities, all through an extensive Lua API.
- Give mobs orders: Send any mob walking to a spot, following or fleeing from someone, standing guard or attacking a target. An order only borrows the mob's attention: when it's done, the mob goes back to its own business.
- Play with bots: Spawn bot players that join like real players and that spells control: they walk, fight, dig, build and chat, so you can play-test a mini-game alone or have companions at your side.
- React to events: Respond when players join, break blocks or swing tools, and cancel or extend what happens next.
- Add your own commands: Register Brigadier commands at runtime, with typed arguments and auto-completion.
- Code with autocompletion: Write spells in Visual Studio Code with full type support.
- Stay in control: Spells run on a per-tick budget and yield automatically, so a busy spell doesn't freeze your server. Access is controlled by permission levels and nodes, compatible with LuckPerms. Use
/wol spell list all to see what's running and /wol spell break all to stop it.
- Install on the server only: Works in singleplayer and multiplayer. Players don't need to install anything.
What People Build
- Safe zones where PvP is disabled
- Minecarts that climb ladders
- A magic wand that strikes hostile mobs with lightning
- A spider bodyguard that stays at your side and attacks whoever hurts you
- Piglin guards who hold their posts against hostile mobs without chasing them too far
- A squire, a bot player who follows you, fights at your side behind its shield, and holds a spot when you tell it to
- A piglin miner who digs a tunnel, lights it with torches, and fetches a fresh pickaxe from a chest when his breaks
- A lumberjack spell that makes the whole tree fall when any player breaks a single log
- A magic hoe that harvests a whole wheat field with one swing
- Mini-games like Journey
Versioning
Versions follow the format MAJOR.MINOR.PATCH-MCVERSION, for example 8.0.0-1.21.11. The first part follows Semantic Versioning and describes compatibility with your scripts. The part after the - is the Minecraft version.
Updates that raise MINOR or PATCH are safe. If MAJOR increases, check the changelog first, because your scripts may need changes.
Learn More
This mod is a complete rewrite for Fabric and NeoForge of the original Wizards of Lua for Forge, which is no longer maintained. The two APIs differ, and scripts written for the Forge version won't run unchanged.
New here? Watch the Quickstart Video, then find guides, examples and the full API reference at wizards-of-lua.net.
评论 0
登录后参与评分
还没有评论,来抢沙发吧