-- entity_zone.lua -- Scripted by perelect. 02.1.2016 -- Assign this script to a trigger zone. reset_entity = {} entity_number = {} zone_number = {} entity_inzone = {} zone_name = {} reset_locked = {} function entity_zone_init_name(e,name) reset_entity[e] = 0 entity_number[e] = 0 zone_number[e] = 0 entity_inzone[e] = 0 zone_name[e] = name reset_locked[e] = 0 end function entity_zone_main(e) GetEntityInZone(e) -- you need to call this first to populate the 'entityinzone' field. if g_Entity[e]['entityinzone']~= nil then entity_number[e] = g_Entity[e]['entityinzone'] end -- This sets up the Reset Entity, which is the entity that is placed in the zone and it needs to stay in the zone all the time. --(Bug Note: Use entity's with the lowest entity number ie: 1,2, etc) if reset_entity[e] == 0 and entity_number[e] > 0 and reset_locked[e] == 0 then reset_entity[e] = entity_number[e] zone_number[e] = e reset_locked[e] = 1 end -- This detects entity's moving in and out of the trigger zone if reset_locked[e] == 1 then if entity_number[e] ~= reset_entity[e] and g_Entity[e]['entityinzone']>0 then entity_inzone[e] = 1 -- flag created, an entity is in the zone, other than the reset entity. else entity_inzone[e] = 0 -- flag created, no new entity is in the zone, other than the reset entity. entity_number[e] = "" end end --Debug Prompts PromptLocal(e,zone_name[e].." | Flag: "..entity_inzone[e].." | Ent#: "..entity_number[e]) --PromptLocal(e,zone_name[e].."| Reset#: "..reset_entity[e].." | Flag: "..entity_inzone[e].." | Ent#: "..entity_number[e]) end