• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Global Event

natanal99

New Member
Joined
May 31, 2011
Messages
67
Reaction score
3
i want to do a global event to check if a monster x is alive anywere in map and the only way i know to check if the monster is alive é by checking every single tile in map.
Is there a better way to do it?
 
Ehh..
Edit: Assuming TFS 1.1 (stable).

Code:
// Creature(id or name or userdata)

Returns the creature. So
Code:
local CreatureID = Creature("Demon Boss")
if CreatureID ~= nil then
       -- If creature exists!
else
      -- If creature doesnt exist.
end

If there's multiple creatures with the same name and you want to execute code on all of them..
Code:
local CreatureID = Creature("Demon")
if CreatureID ~= nil then
        for _,pid in ipairs(CreatureID) do
           --- All creatures now had ID pid. Execute code on pid as creatureid.
        end
else
      -- If no creature
end
 
Well depends what you are checking, a boss? or a area with monsters and etc...

There is few ways to handle this. First one, which has been already explained by @kyoushirou. Second would Game.getSpectators to check area or thrid would use global storage. When it's die then it should add BOSS_DEAD = 1 and when it respawn then BOSS_DEAD = 0.
 

Similar threads

Back
Top