Class engine.Zone

Defines a zone: a set of levels, with depth, npcs, objects, level generator, ...

Tables

engine.Zone.ego_rules

List of rules to run through when applying an ego to an entity.

Fields

engine.Zone._load_zone

Loads basic entities lists

engine.Zone.name

Forced ego

Methods

engine.Zone:addEgoRule (kind, rule)

Adds an ego rule.

engine.Zone:setup (t)

Setup classes to use for level generation Static method

engine.Zone:enableLastPersistZones (max)

Set a cache of the last visited zones Static method Zones will be kept in memory (up to max last zones) and the cache will be used to reload, removing the need for disk load, thus speeding up loading

engine.Zone:init (short_name, dynamic)

Loads a zone definition

engine.Zone:updateBaseLevel ()

Computes the current base level based on the zone infos

engine.Zone:getBaseName ()

Returns the base folder containing the zone

engine.Zone:getCurrentLoadingZone ()

Gets the currently loading zone

engine.Zone:leave ()

Leaves a zone Saves the zone to a .teaz file if requested with persistent="zone" flag

engine.Zone:computeRarities (type, list, level, filter, add_level, rarity_field)

Parses the npc/objects list and compute rarities for random generation ONLY entities with a rarity properties will be considered.
This means that to get a never-random entity you simply do not put a rarity property on it.

engine.Zone:checkFilter (e, filter, type)

Checks an entity against a filter

engine.Zone:filterToString (filter)

Return a string describing the filter

engine.Zone:pickEntity (list)

Picks an entity from a computed probability list

engine.Zone:generateEgoEntities (level, type, etype, e_egos, e___CLASSNAME)

Compute posible egos for this list

engine.Zone:getEgosList (level, type, group, class)

Gets the possible egos

engine.Zone:makeEntity (level, type, filter, force_level, prob_filter)

Picks and resolve an entity

engine.Zone:makeEntityByName (level, type, name, force_unique)

Find a given entity and resolve it

engine.Zone:finishEntity (level, type, e, ego_filter)

Finishes generating an entity

engine.Zone:addEntity (level, e, typ, x, y, no_added)

Do the various stuff needed to setup an entity on the level Grids do not really need that, this is mostly done for traps, objects and actors
This will do all the correct initializations and setup required

engine.Zone:loaded ()

If we are loaded we need a new uid

engine.Zone:onLoadZoneFile (basedir)

Called when the zone file is loaded Does nothing, overload it

engine.Zone:leaveLevel (no_close, lev, old_lev)

Leave the level, forgetting uniques and such

engine.Zone:getLevel (game, lev, old_lev, no_close)

Asks the zone to generate a level of level "lev"

engine.Zone:runPostGeneration (level)

Modules should call this method when done generating a level to run any callbacks registered by generators



Tables

engine.Zone.ego_rules
List of rules to run through when applying an ego to an entity.

Fields

engine.Zone._load_zone
Loads basic entities lists
engine.Zone.name
Forced ego

Methods

engine.Zone:addEgoRule (kind, rule)
Adds an ego rule. Static method

Parameters:

  • kind
  • rule
engine.Zone:setup (t)
Setup classes to use for level generation Static method

Parameters:

  • t table that contains the name of the classes to use

Usage:

     Required fields:
     npc_class (default engine.Actor)
     grid_class (default engine.Grid)
     object_class (default engine.Object)
engine.Zone:enableLastPersistZones (max)
Set a cache of the last visited zones Static method Zones will be kept in memory (up to max last zones) and the cache will be used to reload, removing the need for disk load, thus speeding up loading

Parameters:

  • max
engine.Zone:init (short_name, dynamic)
Loads a zone definition

Parameters:

  • short_name the short name of the zone to load, if should correspond to a directory in your module data/zones/short_name/ with a zone.lua, npcs.lua, grids.lua and objects.lua files inside
  • dynamic
engine.Zone:updateBaseLevel ()
Computes the current base level based on the zone infos
engine.Zone:getBaseName ()
Returns the base folder containing the zone
engine.Zone:getCurrentLoadingZone ()
Gets the currently loading zone
engine.Zone:leave ()
Leaves a zone Saves the zone to a .teaz file if requested with persistent="zone" flag
engine.Zone:computeRarities (type, list, level, filter, add_level, rarity_field)
Parses the npc/objects list and compute rarities for random generation ONLY entities with a rarity properties will be considered.
This means that to get a never-random entity you simply do not put a rarity property on it.

Parameters:

  • type
  • list
  • level
  • filter
  • add_level
  • rarity_field
engine.Zone:checkFilter (e, filter, type)
Checks an entity against a filter

Parameters:

  • e
  • filter
  • type
engine.Zone:filterToString (filter)
Return a string describing the filter

Parameters:

  • filter
engine.Zone:pickEntity (list)
Picks an entity from a computed probability list

Parameters:

  • list
engine.Zone:generateEgoEntities (level, type, etype, e_egos, e___CLASSNAME)
Compute posible egos for this list

Parameters:

  • level
  • type
  • etype
  • e_egos
  • e___CLASSNAME
engine.Zone:getEgosList (level, type, group, class)
Gets the possible egos

Parameters:

  • level
  • type
  • group
  • class Already loaded ? use it
engine.Zone:makeEntity (level, type, filter, force_level, prob_filter)
Picks and resolve an entity

Parameters:

  • level a Level object to generate for
  • type one of "object" "terrain" "actor" "trap"
  • filter a filter table
  • force_level if not nil forces the current level for resolvers to this one
  • prob_filter if true a new probability list based on this filter will be generated, ensuring to find objects better but at a slightly slower cost (maybe)

Returns:

    nil if a filter was given an nothing found

Or

    the fully resolved entity, ready to be used on a level
engine.Zone:makeEntityByName (level, type, name, force_unique)
Find a given entity and resolve it

Parameters:

  • level
  • type
  • name
  • force_unique

Returns:

    nil if a filter was given an nothing found

Or

    the fully resolved entity, ready to be used on a level
engine.Zone:finishEntity (level, type, e, ego_filter)
Finishes generating an entity

Parameters:

  • level
  • type
  • e
  • ego_filter
engine.Zone:addEntity (level, e, typ, x, y, no_added)
Do the various stuff needed to setup an entity on the level Grids do not really need that, this is mostly done for traps, objects and actors
This will do all the correct initializations and setup required

Parameters:

  • level the level on which to add the entity
  • e the entity to add
  • typ the type of entity, one of "actor", "object", "trap" or "terrain"
  • x the coordinates where to add it. This CAN be null in which case it wont be added to the map
  • y the coordinates where to add it. This CAN be null in which case it wont be added to the map
  • no_added have we added it
engine.Zone:loaded ()
If we are loaded we need a new uid
engine.Zone:onLoadZoneFile (basedir)
Called when the zone file is loaded Does nothing, overload it

Parameters:

  • basedir
engine.Zone:leaveLevel (no_close, lev, old_lev)
Leave the level, forgetting uniques and such

Parameters:

  • no_close
  • lev
  • old_lev Before doing anything else, close the current level
engine.Zone:getLevel (game, lev, old_lev, no_close)
Asks the zone to generate a level of level "lev"

Parameters:

  • game which Game?
  • lev the level number going to (from 1 to zone.max_level)
  • old_lev level number leaving from
  • no_close pass to leaveLevel

Returns:

    a Level object
engine.Zone:runPostGeneration (level)
Modules should call this method when done generating a level to run any callbacks registered by generators

Parameters:

  • level
generated by LDoc 1.4.3