迷你世界UGC3.0脚本Wiki


Menu
On this page
Sidebar Navigation
快速入门
欢迎
MOD、组件介绍
什么是Lua编程
组件介绍
组件说明
组件互相操作
组件函数
组件属性
事件
触发器事件管理
组件事件管理
函数库
服务模块
世界模块管理接口 World
对象模块管理接口 GameObject
角色模块管理接口 Actor
玩家模块管理接口 Player
生物模块管理接口 Monster
方块模块管理接口 Block
道具模块管理接口 Item
背包模块管理接口 Backpack
界面模块管理接口 CustomUI
图文信息模块管理接口 Graphics
区域模块管理接口 Area
容器模块管理接口 WorldContainer
资源模块管理接口 Mod
计时器模块管理接口 Timer
状态模块管理接口 Buff
消息模块管理接口 Chat
普通变量数据管理接口 Data
数组变量数据管理接口 Array
二维表变量数据管理接口 Table
KV表变量数据管理接口 Map
全局函数
全局函数
枚举
枚举库
脚本常见问题
开发者常见问题
进阶指南
全局函数
触发器脚本交互
对象介绍
KV&排行榜介绍
二维表介绍
道具实例
更新日志
更新日志
触发器事件管理
添加监听函数调用方式参考 : 组件函数
简单示例:
--这个脚本的作用是当玩家点击草块时,把草块变成钛合金
-- 官方定义的函数,不能修改变动
local Script = {}
-- 组件启动时调用
function Script:OnStart()
-- 玩家点击方块事件
self:AddTriggerEvent(TriggerEvent.PlayerClickBlock, self.Player_Click)
--AddTriggerEvent(TriggerEvent.PlayerClickBlock是官方提供的事件监听,可以在wiki中查看更多的事件
--self.Player_Click 是自定义的一个函数名,可以改成其他你喜欢的
end
-- 定义事件触发时的动作
function Script:Player_Click(event)
local param = event.CurEventParam
-- 玩家点击方块时,判断点的是否是草块
if event.blockid == 100 then
local success = Block:ReplaceBlock(452, event.x, event.y, event.z)
-- Block:ReplaceBlock是官方提供的放置方块方法,可以在wiki中查看更多的方法
-- local success 用来接收Block:ReplaceBlock运行后的结果,可以用来做是否成功放置的判断
end
end
-- 官方定义的函数,不能修改变动
return Script
方块
序号 事件名 事件名描述
0 TriggerEvent.BlockAdd 方块被创建
1 TriggerEvent.BlockRemove 当 方块 被被破坏
2 TriggerEvent.BlockDigBegin 当 方块 被被挖掘
3 TriggerEvent.BlockDigEnd 当 方块 被被挖掘完毕
4 TriggerEvent.BlockDigCancel 当 方块 被被挖掘中断
5 TriggerEvent.BlockTrigger 当 方块 开关状态 发生改变
6 TriggerEvent.BlockChangeColor 当 方块 颜色 发生改变
7 TriggerEvent.BlockChangeDir 当 方块 方向 发生改变
8 TriggerEvent.BlockContainerChange 当 储存容器 内 发生改变
9 TriggerEvent.BlockContainerPutIn 当 储存容器 内 放入道具
10 TriggerEvent.BlockContainerTakeOut 当 储存容器 内 取出道具
方块被创建
事件名: TriggerEvent.BlockAdd
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
当 方块 被被破坏
事件名: TriggerEvent.BlockRemove
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
eventobjid 触发事件的对象
actorid 触发事件的生物类型
当 方块 被被挖掘
事件名: TriggerEvent.BlockDigBegin
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
eventobjid 触发事件的对象
actorid 触发事件的生物类型
当 方块 被被挖掘完毕
事件名: TriggerEvent.BlockDigEnd
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
eventobjid 触发事件的对象
actorid 触发事件的生物类型
当 方块 被被挖掘中断
事件名: TriggerEvent.BlockDigCancel
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
eventobjid 触发事件的对象
actorid 触发事件的生物类型
当 方块 开关状态 发生改变
事件名: TriggerEvent.BlockTrigger
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
当 方块 颜色 发生改变
事件名: TriggerEvent.BlockChangeColor
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
当 方块 方向 发生改变
事件名: TriggerEvent.BlockChangeDir
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
当 储存容器 内 发生改变
事件名: TriggerEvent.BlockContainerChange
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
itemid 事件中的道具类型
当 储存容器 内 放入道具
事件名: TriggerEvent.BlockContainerPutIn
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
itemid 事件中的道具类型
当 储存容器 内 取出道具
事件名: TriggerEvent.BlockContainerTakeOut
事件传参:
参数名 说明
x,y,z 事件中的位置
blockid 事件中的方块类型
itemid 事件中的道具类型