landsandboat/scripts/commands/setstage.lua
claywar 55de6a5440
Fix issues reported in command scripts
Additional nil checks
2024-08-25 12:01:53 -04:00

36 lines
807 B
Lua

-----------------------------------
-- func: setStage
-- desc: changes stage inside an instance
-----------------------------------
---@type TCommand
local commandObj = {}
commandObj.cmdprops =
{
permission = 1,
parameters = 'i'
}
commandObj.onTrigger = function(player, stage)
local zone = player:getZone()
if not zone then
return
end
if zone:getTypeMask() == xi.zoneType.INSTANCED then
local instance = player:getInstance()
if not instance then
return
end
local startStage = instance:getStage()
instance:setStage(stage)
player:printToPlayer(string.format('Stage changed from %i to %i', startStage, stage))
else
player:printToPlayer('Must be in an Instanced zone')
end
end
return commandObj