function pos_transform(str)
-- x座标
locate = string.find(str, ",", 1)
x = string.sub(str, 1, locate - 1)
str = string.gsub(str, x .. ",", "", 1)
x = math.floor(x)
-- y座标
locate = string.find(str, ",", 1)
y = string.sub(str, 1, locate - 1)
str = string.gsub(str, y .. ",", "", 1)
y = math.floor(y)
-- z座标
z = math.floor(str)
return {x = x, y = y, z = z}
end
-- 重置装置方块
function Reset(onoff, position)
if onoff == false then
return
end
EntityBlock = Game.EntityBlock:Create(pos_transform(position))
EntityBlock:Event({action = "reset"})
end
-- 传送玩家位置
function Convey(onoff, position)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.position = pos_transform(position)
end
-- 增加玩家金币
function Add_coin(onoff, coin)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.coin = player.coin + math.floor(coin)
end
-- 更改玩家金币
function Change_coin(onoff, coin)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.coin = math.floor(coin)
end
-- 更改玩家最大血量
function Change_maxhealth(onoff, maxhealth)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.maxhealth = math.floor(maxhealth)
end
-- 增加玩家最大血量
function Add_maxhealth(onoff, maxhealth)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.maxhealth = player.maxhealth + math.floor(maxhealth)
end
-- 更改玩家血量
function Change_health(onoff, health)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.health = math.floor(health)
end
-- 增加玩家血量
function Add_health(onoff, health)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.health = player.health + math.floor(health)
end
-- 更改玩家最大护甲
function Change_maxarmor(onoff, maxarmor)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.maxarmor = math.floor(maxarmor)
end
-- 增加玩家最大护甲
function Add_maxarmor(onoff, maxarmor)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.maxarmor = player.maxarmor + math.floor(maxarmor)
end
-- 更改玩家护甲
function Change_armor(onoff, armor)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.armor = math.floor(armor)
end
-- 更改玩家护甲
function Add_armor(onoff, armor)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player.armor = player.armor + math.floor(armor)
end
-- 杀死玩家
function Kill(onoff)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player:Kill()
end
-- 移除武器
function Remove_weapon(onoff)
if onoff == false then
return
end
if Game.GetTriggerEntity() ~= nil then
player = Game.GetTriggerEntity():ToPlayer()
else
return
end
player:RemoveWeapon()
end
-- 所有玩家复活
function Allplayer_spawn(onoff)
if onoff == false then
return
end
Game.Rule:Respawn()
end