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:addEmote (e) Adds an existing emote to the map
_M:addObject (x, y, o) Object functions
_M:addParticleEmitter (e) Adds an existing particle emitter to the map
_M:addPathString (ps) Adds a "path string" to the map "Path strings" are strings defining what terrain an actor can cross.
_M:apply (x, y, v) Sets a grid as seen and remembered Used by FOV code
_M:applyESP (x, y, v) Sets a grid as seen if ESP'ed Used by FOV code
_M:applyLite (x, y, v) 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 (x, y) Displays the map on a surface
_M:displayEffects () Display the overlay effects, called by self:display()
_M:displayEmotes () Display the emotes, 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:isOnScreen (x, y) Checks the given coords to see if they are displayed on screen
_M:liteAll (x, y, w, h) Lite all grids
_M:minimapDisplay (dx, dy, x, y, w, h, transp) Displays the minimap
_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, 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:removeEmote (e) Removes an emote from the map
_M:removeParticleEmitter (e) Removes a particle emitter from the map
_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, allow_backcolor) 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.
_M:setZoom (zoom, tmx, tmy) Sets zoom level
_M:updateMap (x, y) Updates the map on the given spot This updates many things, from the C map object, the FOV caches, the minimap if it exists, ...


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: either a simple display entity to draw upon the map or a Particle class
  • 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:addEmote (e)
Adds an existing emote to the map

Parameters

  • e:
_M:addObject (x, y, o)
Object functions

Parameters

  • x:
  • y:
  • o:
_M:addParticleEmitter (e)
Adds an existing particle emitter to the map

Parameters

  • e:
_M:addPathString (ps)
Adds a "path string" to the map "Path strings" are strings defining what terrain an actor can cross. Their format is left to the module to decide (by overloading Actor:getPathString() )
They are totally optional as they re only used to compute A* paths adn the likes and even then the algorithms still work without them, only slower
If you use them the block_move function of your Grid class must be able to handle either an actor or a "path string" as their third argument

Parameters

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

Parameters

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

Parameters

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

Parameters

  • x:
  • y:
  • v:
_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 (x, y)
Displays the map on a surface

Parameters

  • x:
  • y:

Return value:

a surface containing the drawn map
_M:displayEffects ()
Display the overlay effects, called by self:display()
_M:displayEmotes ()
Display the emotes, 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:isOnScreen (x, y)
Checks the given coords to see if they are displayed on screen

Parameters

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

Parameters

  • x:
  • y:
  • w:
  • h:
_M:minimapDisplay (dx, dy, x, y, w, h, transp)
Displays the minimap

Parameters

  • dx:
  • dy:
  • x:
  • y:
  • w:
  • h:
  • transp:

Return value:

a surface containing the drawn map
_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, args)
Add a new particle emitter

Parameters

  • x:
  • y:
  • radius:
  • def:
  • 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:removeEmote (e)
Removes an emote from the map

Parameters

  • e:
_M:removeParticleEmitter (e)
Removes a particle emitter from the map

Parameters

  • e:
_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, allow_backcolor)
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:
  • allow_backcolor:
_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:
_M:setZoom (zoom, tmx, tmy)
Sets zoom level

Parameters

  • zoom: nil to reset to default, ortherwise a number to increment the zoom with
  • tmx: make sure this coords are visible after zoom (can be nil)
  • tmy: make sure this coords are visible after zoom (can be nil)
_M:updateMap (x, y)
Updates the map on the given spot This updates many things, from the C map object, the FOV caches, the minimap if it exists, ...

Parameters

  • x:
  • y:

Valid XHTML 1.0!