Module ...

Represents a level map, handles display and various low level map work

Functions

_M:addEffect (src, x, y, duration, damtype, dam, radius, dir, angle, overlay, update_fct, friendlyfire) Adds a zone (temporary) effect
_M:addObject (x, y, o) Object functions
_M:apply (x, y) Sets a grid as seen and remembered Used by FOV code
_M:applyESP (x, y) Sets a grid as seen if ESP'ed Used by FOV code
_M:applyLite (x, y) Sets a grid as seen, lited and remembered Used by FOV code
_M:call (x, y, pos, entity) Sets/gets a value from the map It is defined as the function metamethod, so one can simply do: mymap(x, y, Map.TERRAIN)
_M:centerViewAround (x, y) Sets the current view area with the given coords at the center
_M:checkAllEntities (x, y, what, ...) Check all entities of the grid for a property
_M:checkEntity (x, y, pos, what, ...) Check specified entity position of the grid for a property
_M:checkMapViewBounded () Checks the map is bound to the screen (no "empty space" if the map is big enough)
_M:cleanFOV () Cleans the FOV infos (seens table)
_M:close () Closes things in the object to allow it to be garbage collected Map objects are NOT automatically garbage collected because they contain FOV C structure, which themselves have a reference to the map.
_M:display () Displays the map on a surface
_M:displayEffects () Display the overlay effects, called by self:display()
_M:displayParticles () Display the particle emiters, called by self:display()
_M:getMouseTile (mx, my) Gets the tile under the mouse
_M:getTileToScreen (tx, ty) Get the screen position corresponding to a tile
_M:import (map, dx, dy, sx, sy, sw, sh) Import a map into the current one
_M:init (w, h) Creates a map
_M:isBound (x, y) Checks the given coords to see if they are in bound
_M:liteAll (x, y, w, h) Lite all grids
_M:moveViewSurround (x, y, marginx, marginy) Sets the current view area if x and y are out of bounds
_M:opaque (x, y) Sets checks if a grid lets sigth pass through Used by FOV code
_M:opaqueESP (x, y) Sets checks if a grid lets ESP pass through Used by FOV ESP code
_M:particleEmitter (x, y, radius, def, fct, max, args) Add a new particle emitter
_M:processEffects () Process the overlay effects, call it from your tick function
_M:recreate () Recreate the internal map using new dimensions
_M:redisplay () Redisplays the map, storing seen information
_M:rememberAll (x, y, w, h) Remember all grids
_M:remove (x, y, pos) Removes an entity
_M:resetTiles () Create the tile repositories
_M:save () Serialization
_M:setObscure (r, g, b, a) Defines the "obscure" factor of unseen map By default it is 0.6, 0.6, 0.6, 1
_M:setShown (r, g, b, a) Defines the "shown" factor of seen map By default it is 1, 1, 1, 1
_M:setViewPort (x, y, w, h, tile_w, tile_h, fontname, fontsize, multidisplay) Sets the viewport size Static
_M:setViewerActor (player) Defines the actor that sees the map Usualy this will be the player.
_M:setViewerFaction (faction, friend, neutral, enemy) Defines the faction of the person seeing the map Usualy this will be the player's faction.


Functions

_M:addEffect (src, x, y, duration, damtype, dam, radius, dir, angle, overlay, update_fct, friendlyfire)
Adds a zone (temporary) effect

Parameters

  • src: the source actor
  • x: the epicenter coords
  • y: the epicenter coords
  • duration: the number of turns to persist
  • damtype: the DamageType to apply
  • dam:
  • radius: the radius of the effect
  • dir: the numpad direction of the effect, 5 for a ball effect
  • angle:
  • overlay: a simple display entity to draw upon the map
  • update_fct: optional function that will be called each time the effect is updated with the effect itself as parameter. Use it to change radius, move around ....
  • friendlyfire:
_M:addObject (x, y, o)
Object functions

Parameters

  • x:
  • y:
  • o:
_M:apply (x, y)
Sets a grid as seen and remembered Used by FOV code

Parameters

  • x:
  • y:
_M:applyESP (x, y)
Sets a grid as seen if ESP'ed Used by FOV code

Parameters

  • x:
  • y:
_M:applyLite (x, y)
Sets a grid as seen, lited and remembered Used by FOV code

Parameters

  • x:
  • y:
_M:call (x, y, pos, entity)
Sets/gets a value from the map It is defined as the function metamethod, so one can simply do: mymap(x, y, Map.TERRAIN)

Parameters

  • x: position
  • y: position
  • pos: what kind of entity to set(Map.TERRAIN, Map.OBJECT, Map.ACTOR)
  • entity: the entity to set, if null it will return the current one
_M:centerViewAround (x, y)
Sets the current view area with the given coords at the center

Parameters

  • x:
  • y:
_M:checkAllEntities (x, y, what, ...)
Check all entities of the grid for a property

Parameters

  • x: position
  • y: position
  • what: property to check
  • ...:
_M:checkEntity (x, y, pos, what, ...)
Check specified entity position of the grid for a property

Parameters

  • x: position
  • y: position
  • pos: entity position in the grid
  • what: property to check
  • ...:
_M:checkMapViewBounded ()
Checks the map is bound to the screen (no "empty space" if the map is big enough)
_M:cleanFOV ()
Cleans the FOV infos (seens table)
_M:close ()
Closes things in the object to allow it to be garbage collected Map objects are NOT automatically garbage collected because they contain FOV C structure, which themselves have a reference to the map. Cyclic references! BAD BAD BAD !
The closing should be handled automatically by the Zone class so no bother for authors
_M:display ()
Displays the map on a surface

Return value:

a surface containing the drawn map
_M:displayEffects ()
Display the overlay effects, called by self:display()
_M:displayParticles ()
Display the particle emiters, called by self:display()
_M:getMouseTile (mx, my)
Gets the tile under the mouse

Parameters

  • mx:
  • my:
_M:getTileToScreen (tx, ty)
Get the screen position corresponding to a tile

Parameters

  • tx:
  • ty:
_M:import (map, dx, dy, sx, sy, sw, sh)
Import a map into the current one

Parameters

  • map: the map to import
  • dx: coordinate where to import it in the current map
  • dy: coordinate where to import it in the current map
  • sx: coordinate where to start importing the map, defaults to 0
  • sy: coordinate where to start importing the map, defaults to 0
  • sw: size of the imported map to get, defaults to map size
  • sh: size of the imported map to get, defaults to map size
_M:init (w, h)
Creates a map

Parameters

  • w: width (in grids)
  • h: height (in grids)
_M:isBound (x, y)
Checks the given coords to see if they are in bound

Parameters

  • x:
  • y:
_M:liteAll (x, y, w, h)
Lite all grids

Parameters

  • x:
  • y:
  • w:
  • h:
_M:moveViewSurround (x, y, marginx, marginy)
Sets the current view area if x and y are out of bounds

Parameters

  • x:
  • y:
  • marginx:
  • marginy:
_M:opaque (x, y)
Sets checks if a grid lets sigth pass through Used by FOV code

Parameters

  • x:
  • y:
_M:opaqueESP (x, y)
Sets checks if a grid lets ESP pass through Used by FOV ESP code

Parameters

  • x:
  • y:
_M:particleEmitter (x, y, radius, def, fct, max, args)
Add a new particle emitter

Parameters

  • x:
  • y:
  • radius:
  • def:
  • fct:
  • max:
  • args:
_M:processEffects ()
Process the overlay effects, call it from your tick function
_M:recreate ()
Recreate the internal map using new dimensions
_M:redisplay ()
Redisplays the map, storing seen information
_M:rememberAll (x, y, w, h)
Remember all grids

Parameters

  • x:
  • y:
  • w:
  • h:
_M:remove (x, y, pos)
Removes an entity

Parameters

  • x: position
  • y: position
  • pos: what kind of entity to set(Map.TERRAIN, Map.OBJECT, Map.ACTOR)
_M:resetTiles ()
Create the tile repositories
_M:save ()
Serialization
_M:setObscure (r, g, b, a)
Defines the "obscure" factor of unseen map By default it is 0.6, 0.6, 0.6, 1

Parameters

  • r:
  • g:
  • b:
  • a:
_M:setShown (r, g, b, a)
Defines the "shown" factor of seen map By default it is 1, 1, 1, 1

Parameters

  • r:
  • g:
  • b:
  • a:
_M:setViewPort (x, y, w, h, tile_w, tile_h, fontname, fontsize, multidisplay)
Sets the viewport size Static

Parameters

  • x: screen coordonate where the map will be displayed (this has no impact on the real display). This is used to compute mouse clicks
  • y: screen coordonate where the map will be displayed (this has no impact on the real display). This is used to compute mouse clicks
  • w: width
  • h: height
  • tile_w: width of a single tile
  • tile_h: height of a single tile
  • fontname: font parameters, can be nil
  • fontsize: font parameters, can be nil
  • multidisplay:
_M:setViewerActor (player)
Defines the actor that sees the map Usualy this will be the player. This is used to determine invisibility/...

Parameters

  • player:
_M:setViewerFaction (faction, friend, neutral, enemy)
Defines the faction of the person seeing the map Usualy this will be the player's faction. If you do not want to use tactical display, dont use it

Parameters

  • faction:
  • friend:
  • neutral:
  • enemy:

Valid XHTML 1.0!