迷你世界api 系统事件

本文详细介绍了迷你世界游戏的API系统事件,包括游戏开始、运行、结束等逻辑事件,以及玩家死亡、复活、背包物品变动等玩家事件。通过示例代码展示了如何注册监听并响应这些事件,帮助开发者实现游戏内的交互和逻辑控制。
摘要由CSDN通过智能技术生成

迷你世界api 系统事件

游戏活动管理
只需添加需要监视的事件,而无需创建事件对象,如下所示:

--Game Event---
ScriptSupportEvent:registerEvent([=[Game.Start]=], Game_StartGame)
ScriptSupportEvent:registerEvent([=[Game.Run]=], Game_Update)
ScriptSupportEvent:registerEvent([=[Game.End]=], Game_GameOver)
--Player Event---
ScriptSupportEvent:registerEvent([=[Player.Die]=], Player_Dead)
ScriptSupportEvent:registerEvent([=[Player.Revive]=], Player_Revive)
ScriptSupportEvent:registerEvent([=[Player.AddItem]=], BackPack_AddItem)
--Block Event---
ScriptSupportEvent:registerEvent([=[Block.Add]=], Block_Add)
ScriptSupportEvent:registerEvent([=[Block.DestroyBy]=], Block_Destroy)
ScriptSupportEvent:registerEvent([=[Block.Trigger]=], Block_Trigger)

游戏事件类型和说明
没有。 事件类型 描述
1个 世界大赛 地图中的相关事件
2 逻辑事件 游戏逻辑相关事件
3 玩家事件 玩家相关事件
4 生物事件 生物相关事件
5 封锁事件 阻止相关事件
6 项目事件 项目相关事件
7 粒子事件 粒子相关事件
世界大赛(世界)
名称 描述 参数
天气变化 天气变化 没有
Backpack.ItemTakeOut 容器有物品输出 {blockid,x,y,z,itemid,itemnum}1.1+
Backpack.ItemPutIn 容器有物品输入 {blockid,x,y,z,itemid,itemnum}1.1+
Backpack.ItemChange 背包栏的变更 {blockid,x,y,z,itemid,itemnum}
世界事件相关示例:

--Write a function, just named when the Change of weather will perform this function
local function Weather_Changed()
	Chat:sendSystemMsg("Incident: Change of weather")
end
--Registered listeners, Change the function of the Executive Weather_Changed when weather
--The first parameter is listening event, the second parameter Weather_Changed function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Weather.Changed]=],Weather_Changed)
--Write a function, just named when the Change of backpack bar will perform this function
local function Backpack_ItemChange(event)
	Chat:sendSystemMsg("Incident: Change of backpack bar")
	Chat:sendSystemMsg("Parameter blockid as:" .. event.blockid)
	Chat:sendSystemMsg("Parameter x is:" .. event.x)
	Chat:sendSystemMsg("Parameter y is:" .. event.y)
	Chat:sendSystemMsg("The parameter z as:" .. event.z)
	Chat:sendSystemMsg("Parameter itemid as:" .. event.itemid)
	Chat:sendSystemMsg("Parameter itemnum as:" .. event.itemnum)
end
--Registered listeners, Change of backpack bar when a function execution Backpack_ItemChange
--The first parameter is listening event, the second parameter Backpack_ItemChange function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Backpack.ItemChange]=],Backpack_ItemChange)

逻辑事件相关示例:

--Write a function, just named, when Any player is defeated will perform this function
local function Game_AnyPlayer_Defeat(event)
	Chat:sendSystemMsg("Incident: Any player is defeated")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter toobjid as:" .. event.toobjid)
end
--Registered listeners when the function execution Game_AnyPlayer_Defeat Any player is defeated
--The first parameter is listening event, the second parameter Game_AnyPlayer_Defeat function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.AnyPlayer.Defeat]=],Game_AnyPlayer_Defeat)
复制!
--Write a function, just named, when Any player enters game when this function is executed
local function Game_AnyPlayer_EnterGame(event)
	Chat:sendSystemMsg("Incident: Any player enters game")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter toobjid as:" .. event.toobjid)
end
--Registered listeners, do Game_AnyPlayer_EnterGame function Any player enters game when
--The first parameter is listening event, the second parameter Game_AnyPlayer_EnterGame function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.AnyPlayer.EnterGame]=],Game_AnyPlayer_EnterGame)
复制!
--Write a function, just named, when Any player leaves game will perform this function
local function Game_AnyPlayer_LeaveGame(event)
	Chat:sendSystemMsg("Incident: Any player leaves game")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter toobjid as:" .. event.toobjid)
end
--Registered listeners, do Game_AnyPlayer_LeaveGame function Any player leaves game time
--The first parameter is listening event, the second parameter Game_AnyPlayer_LeaveGame function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.AnyPlayer.LeaveGame]=],Game_AnyPlayer_LeaveGame)
复制!
--Write a function, just named, when Any player wins when this function is executed
local function Game_AnyPlayer_Victory(event)
	Chat:sendSystemMsg("Incident: Any player wins")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter toobjid as:" .. event.toobjid)
end
--Registered listeners when the function execution Game_AnyPlayer_Victory Any player wins
--The first parameter is listening event, the second parameter Game_AnyPlayer_Victory function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.AnyPlayer.Victory]=],Game_AnyPlayer_Victory)
复制!
--Write a function, just named, when Game over will perform this function
local function Game_End()
	Chat:sendSystemMsg("Incident: Game over")
end
--Registered listeners, do Game_End function when Game over
--The first parameter is listening event, the second parameter Game_End function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.End]=],Game_End)
复制!
--Write a function, just named, when the World time is when will perform this function [n]
local function Game_Hour(event)
	Chat:sendSystemMsg("Incident: World time is [n]")
	Chat:sendSystemMsg("Parameter hour as:" .. event.hour)
end
--Registered listeners, World time is executed Game_Hour function when [n]
--The first parameter is listening event, the second parameter Game_Hour function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.Hour]=],Game_Hour)
复制!
--Write a function, just named, when Start game will perform this function
local function Game_Load()
	Chat:sendSystemMsg("Incident: Start game")
end
--Registered listeners, do Game_Load function when Start game
--The first parameter is listening event, the second parameter Game_Load function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.Load]=],Game_Load)
复制!
--Write a function, just named, when the Game is running will perform this function
--This event will be triggered once every 50ms, the internal function call interface should not be sending messages, or chat box will be scraper
local function Game_Run()
	--Chat:sendSystemMsg("Incident: Game is running")
	--Every 50ms to homeowner output increased 1 until the blood is not less than 100
	local result,hp=Player:getAttr(0,2) - Get current health Homeowners
	if hp<100 then-- if the blood is less than 100
		Player:setAttr(0,2, hp + 1) - adding to the blood a homeowner
	end
end
--Registered listeners, do Game_Run function when Game is running
--The first parameter is listening event, the second parameter Game_Run function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.Run]=],Game_Run)
复制!
--Write a function, just named, when the World time is [n] will perform this function when the second
--This event will be triggered once per second, so the internal function call interface should not be sending messages, or chat box will be scraper
local function Game_RunTime(event)
	--Chat:sendSystemMsg("Incident: World time is [n] second")
	--Chat:sendSystemMsg("Second parameter as:" .. event.second)
	--Per second to homeowners hungry increased by one, until the value of not less than 100 hunger
	local result,hunger=Player:getAttr(0,6) - Get the current value of a homeowner hunger
	if hunger<100 then-- If the value is less than 100 hunger
		Player:setAttr(0,6, hunger + 1) - a plus value to a homeowner hunger
	end
end
--Registered listeners, World time is [n] function when the second execution Game_RunTime
--The first parameter is listening event, the second parameter Game_RunTime function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.RunTime]=],Game_RunTime)
复制!
--Write a function, just named, when Game start will perform this function
local function Game_Start()
	Chat:sendSystemMsg("Incident: Game start")
end
--Registered listeners, do Game_Start function when Game start
--The first parameter is listening event, the second parameter Game_Start function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.Start]=],Game_Start)
复制!
--Write a function, just named, when Game timeout will perform this function
local function Game_TimeOver()
	Chat:sendSystemMsg("Incident: Game timeout")
end
--Registered listeners when Game timeout function execution Game_TimeOver
--The first parameter is listening event, the second parameter Game_TimeOver function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Game.TimeOver]=],Game_TimeOver)
复制!
--Write a function, just named, when Any change will do this time of Timer function
local function minitimer_change(event)
	Chat:sendSystemMsg("Incident: Any change of Timer")
	Chat:sendSystemMsg("Parameter timerid as:" .. event.timerid)
	Chat:sendSystemMsg("Parameter timername as:" .. event.timername)
end
--Registered listeners, Any change execution minitimer_change time of Timer function
--The first parameter is listening event, the second parameter minitimer_change function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[minitimer.change]=],minitimer_change)

玩家事件相关示例:

--Write a function, just named when the Add new item will perform this function
local function Player_AddItem(event)
	Chat:sendSystemMsg("Incident: Add new item")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter toobjid as:" .. event.toobjid)
	Chat:sendSystemMsg("Parameter itemid as:" .. event.itemid)
	Chat:sendSystemMsg("Parameter itemnum as:" .. event.itemnum)
end
--Registered listeners when the function execution Player_AddItem Add new item
--The first parameter is listening event, the second parameter Player_AddItem function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Player.AddItem]=],Player_AddItem)
复制!
--Write a function, just named when the Player enters area will perform this function
local function Player_AreaIn(event)
	Chat:sendSystemMsg("Incident: Player enters area")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter areaid as:" .. event.areaid)
end
--Registered listeners, do Player_AreaIn function when Player enters area
--The first parameter is listening event, the second parameter Player_AreaIn function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Player.AreaIn]=],Player_AreaIn)
复制!
--Write a function, just named when the Player leaves area will perform this function
local function Player_AreaOut(event)
	Chat:sendSystemMsg("Incident: Player leaves area")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter areaid as:" .. event.areaid)
end
--Registered listeners, do Player_AreaOut function when Player leaves area
--The first parameter is listening event, the second parameter Player_AreaOut function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Player.AreaOut]=],Player_AreaOut)

生物事件相关示例:

--Write a function, just named, when the Creature enters area will perform this function
local function Actor_AreaIn(event)
	Chat:sendSystemMsg("Incident: Creature enters area")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter areaid as:" .. event.areaid)
end
--Registered listeners, do Actor_AreaIn function when Creature enters area
--The first parameter is listening event, the second parameter Actor_AreaIn function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Actor.AreaIn]=],Actor_AreaIn)
复制!
---Actor.AreaOut---49
--Write a function, just named, when the Creature leaves area will perform this function
local function Actor_AreaOut(event)
	Chat:sendSystemMsg("Incident: Creature leaves area")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter areaid as:" .. event.areaid)
end
--Registered listeners, do Actor_AreaOut function when Creature leaves area
--The first parameter is listening event, the second parameter Actor_AreaOut function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Actor.AreaOut]=],Actor_AreaOut)
复制!
---Actor.Attack---50
--Write a function, just named, when the Creature attacking will perform this function
local function Actor_Attack(event)
	Chat:sendSystemMsg("Incident: Creature attacking")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter toobjid as:" .. event.toobjid)
end
--Registered listeners, execute function when Creature attacking Actor_Attack
--The first parameter is listening event, the second parameter Actor_Attack function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Actor.Attack]=],Actor_Attack)
复制!
---Actor.AttackHit---51
--Write a function, just named, when the Creature attack hits will perform this function
local function Actor_AttackHit(event)
	Chat:sendSystemMsg("Incident: Creature attack hits")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter toobjid as:" .. event.toobjid)
end
--Registered listeners, Creature attack hits execution function when Actor_AttackHit
--The first parameter is listening event, the second parameter Actor_AttackHit function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Actor.AttackHit]=],Actor_AttackHit)

阻止事件相关示例:

--Write a function, just named, when Block is created will perform this function
local function Block_Add(event)
	Chat:sendSystemMsg("Incident: Block is created")
	Chat:sendSystemMsg("Parameter blockid as:" .. event.blockid)
	Chat:sendSystemMsg("Parameter x is:" .. event.x)
	Chat:sendSystemMsg("Parameter y is:" .. event.y)
	Chat:sendSystemMsg("The parameter z as:" .. event.z)
end
--Registered listeners, do Block_Add function when Block is created
--The first parameter is listening event, function that executes when the second argument Block_Add That incident
ScriptSupportEvent:registerEvent([=[Block.Add]=],Block_Add)
复制!
--Write a function, just named, when Block is destoryed will perform this function
local function Block_DestroyBy(event)
	Chat:sendSystemMsg("Incident: Block is destroyed")
	Chat:sendSystemMsg("Parameter eventobjid (opt) as:" .. event.eventobjid (opt))
	Chat:sendSystemMsg("Parameter blockid as:" .. event.blockid)
	Chat:sendSystemMsg("Parameter x is:" .. event.x)
	Chat:sendSystemMsg("Parameter y is:" .. event.y)
	Chat:sendSystemMsg("The parameter z as:" .. event.z)
end
--Registered listeners, do Block_DestroyBy function when Block is destoryed
--The first parameter is listening event, the second parameter Block_DestroyBy function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Block.DestroyBy]=],Block_DestroyBy)
复制!
--Write a function, just named when the Start mining block will perform this function
local function Block_Dig_Begin(event)
	Chat:sendSystemMsg("Incident: Start mining block")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter blockid as:" .. event.blockid)
	Chat:sendSystemMsg("Parameter x is:" .. event.x)
	Chat:sendSystemMsg("Parameter y is:" .. event.y)
	Chat:sendSystemMsg("The parameter z as:" .. event.z)
end
--Registered listeners, do Block_Dig_Begin function when Start mining block
--The first parameter is listening event, the second parameter Block_Dig_Begin function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[Block.Dig.Begin]=],Block_Dig_Begin)

项目活动相关示例:

--Write a function, just named, when Drop item enters area will perform this function
local function DropItem_AreaIn(event)
	Chat:sendSystemMsg("Incident: Drop item enters area")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter areaid as:" .. event.areaid)
	Chat:sendSystemMsg("Parameter itemid (opt) as:" .. event.itemid (opt))
	Chat:sendSystemMsg("Parameter itemnum (opt) as:" .. event.itemnum (opt))
end
--Registered listeners, do DropItem_AreaIn function when Drop item enters area
--The first parameter is listening event, the second parameter DropItem_AreaIn function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[DropItem.AreaIn]=],DropItem_AreaIn)
复制!
--Write a function, just named, when Drop item leaves area will perform this function
local function DropItem_AreaOut(event)
	Chat:sendSystemMsg("Event: Drop item leaves area")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter areaid as:" .. event.areaid)
	Chat:sendSystemMsg("Parameter itemid (opt) as:" .. event.itemid (opt))
	Chat:sendSystemMsg("Parameter itemnum (opt) as:" .. event.itemnum (opt))
end
--Registered listeners, do DropItem_AreaOut function when Drop item leaves area
--The first parameter is listening event, the second parameter DropItem_AreaOut function that is executed when the event occurs
ScriptSupportEvent:registerEvent([=[DropItem.AreaOut]=],DropItem_AreaOut)
复制!
--Write a function, just named when the Item disappear will perform this function
local function Item_Disappear(event)
	Chat:sendSystemMsg("Incident: Item disappear")
	Chat:sendSystemMsg("Parameter eventobjid as:" .. event.eventobjid)
	Chat:sendSystemMsg("Parameter toobjid as:" .. event.toobjid)
	Chat:sendSystemMsg("Parameter itemid as:" .. event.itemid)
	Chat:sendSystemMsg("Parameter itemnum as:" .. event.itemnum)
end

--Registered listeners, Item disappear when the function execution Item_Disappear --The first parameter is listening event, the second parameter Item_Disappear function that is executed when the event occurs ScriptSupportEvent:registerEvent([=[Item.Disappear]=],Item_Disappear)

迷你世界api 系统事件

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值