Class engine.Map

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

Tables

engine.Map.searchOrder

The order of checks for checkAllEntities

Fields

engine.Map.zdepth

The map vertical depth storage

engine.Map.TERRAIN

The place of a terrain entity in a map grid

engine.Map.TRAP

The place of a terrain entity in a map grid

engine.Map.ACTOR

The place of an actor entity in a map grid

engine.Map.PROJECTILE

The place of a projectile entity in a map grid

engine.Map.OBJECT

The place of an object entity in a map grid

engine.Map.TRIGGER

The place of a trigger entity in a map grid

Methods

engine.Map:setViewPort (x, y, w, h, tile_w, tile_h, fontname, fontsize, allow_backcolor)

Sets the viewport size Static

engine.Map:enableFBORenderer (shader)

Setup a fbo/shader pair to display map effects If not set this just uses plain quads

engine.Map:setBoundedPadding (left, right, top, bottom)

Sets the map viewport padding, for scrolling purposes (defaults to 0) Static

engine.Map:setZoom (zoom, tmx, tmy)

Sets zoom level

engine.Map:setObscure (r, g, b, a)

Defines the "obscure" factor of unseen map By default it is 0.6, 0.6, 0.6, 0.6

engine.Map:setShown (r, g, b, a)

Defines the "shown" factor of seen map By default it is 1, 1, 1, 1

engine.Map:resetTiles ()

Create the tile repositories

engine.Map:setViewerFaction (faction)

Defines the faction of the person seeing the map Usually this will be the player's faction.

engine.Map:setViewerActor (player)

Defines the actor that sees the map Usually this will be the player.

engine.Map:init (w, h)

Creates a map

engine.Map:save ()

Serialization

engine.Map:regenGridLines ()

Regenetate grid lines definition if it changed

engine.Map:resetDefaultShader ()

Reset default shader

engine.Map:addPathString (ps)

Adds a "path string" to the map "Path strings" are strings defining what terrain an actor can cross.

engine.Map:recreate ()

Recreate the internal map using new dimensions

engine.Map:redisplay ()

Redisplays the map, storing seen information

engine.Map: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.

engine.Map:cleanFOV ()

Cleans the FOV infos (seens table)

engine.Map: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, ...

engine.Map:call (x, y, pos, e)

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

engine.Map:remove (x, y, pos, only)

Removes an entity

engine.Map:minimapDisplay (dx, dy, x, y, w, h, transp)

Displays the minimap

engine.Map:display (x, y, nb_keyframe, always_show, prevfbo)

Displays the map on screen

engine.Map:zDisplay (z, nb_keyframe, prevfbo)

Called by the engine map draw code for each z-layer

engine.Map:opaque (x, y)

Sets checks if a grid lets sight pass through Used by FOV code

engine.Map:opaqueESP (x, y)

Sets checks if a grid lets ESP pass through Used by FOV ESP code

engine.Map:apply (x, y, v)

Sets a grid as seen and remembered Used by FOV code

engine.Map:applyExtraLite (x, y, v)

Sets a grid as seen, lited and remembered, if it is in the current FOV Used by FOV code

engine.Map:applyLite (x, y, v)

Sets a grid as seen, lited and remembered Used by FOV code

engine.Map:applyESP (x, y, v)

Sets a grid as seen if ESP'ed Used by FOV code

engine.Map:checkAllEntities (x, y, what)

Check all entities of the grid for a property until it finds one/returns one This will stop at the first entity with the given property (or if the property is a function, the return of the function that is not false/nil).

engine.Map:checkAllEntitiesNoStop (x, y, what)

Check all entities of the grid for a property This will iterate over all entities without stopping.

engine.Map:checkAllEntitiesLayersNoStop (x, y, what)

Check all entities of the grid for a property This will iterate over all entities without stopping.

engine.Map:checkAllEntitiesCount (x, y, what)

Check all entities of the grid for a property, counting the results This will iterate over all entities without stopping.

engine.Map:checkEntity (x, y, pos, what)

Check specified entity position of the grid for a property

engine.Map:seeAll (x, y, w, h, v)

See all grids

engine.Map:liteAll (x, y, w, h, v)

Lite all grids

engine.Map:rememberAll (x, y, w, h, v)

Remember all grids

engine.Map:setScroll (x, y)

Sets the current view at a precise location

engine.Map:centerViewAround (x, y)

Sets the current view area with the given coords at the center

engine.Map:moveViewSurround (x, y, marginx, marginy, ignore_padding)

Sets the current view area if x and y are out of bounds

engine.Map:checkMapViewBounded ()

Checks the map is bound to the screen (no "empty space" if the map is big enough)

engine.Map:scrollDir (dir)

Scrolls the map in the given direction

engine.Map:getMouseTile (mx, my)

Gets the tile under the mouse

engine.Map:getTileToScreen (tx, tx, center)

Get the screen position corresponding to a tile

engine.Map:isBound (x, y)

Checks the given coords to see if they are in bound

engine.Map:isOnScreen (x, y)

Checks the given coords to see if they are displayed on screen

engine.Map:getScreenUpperCorner ()

Get the screen offset where to start drawing (upper corner)

engine.Map:import (map, dx, dy, sx, sy, sw, sh)

Import a map into the current one

engine.Map:overlay (map, dx, dy, sx, sy, sw, sh)

Import a map into the current one as an overlay, only replacing defined entities

engine.Map:addEffect (src, x, y, duration, damtype, dam, radius, dir, angle, overlay, update_fct, selffire, friendlyfire)

Adds a zone (temporary) effect

engine.Map:displayEffects (z, prevfbo, nb_keyframes)

Display the overlay effects, called by self:display()

engine.Map:processEffects (update_shape_only)

Process the overlay effects, call it from your tick function

engine.Map:addObject (x, y, o)

Object functions

engine.Map:particleEmitter (x, y, radius, def, args, shader, zdepth)

Add a new particle emitter

engine.Map:addParticleEmitter (e, x, y)

Adds an existing particle emitter to the map

engine.Map:removeParticleEmitter (e)

Removes a particle emitter from the map

engine.Map:removeParticleEmitters ()

Now remove all t he ones registered for removal

engine.Map:displayParticles (z, nb_keyframes)

Display the particle emitters, called by self:display()

engine.Map:addEmote (e)

Adds an existing emote to the map

engine.Map:removeEmote (e)

Removes an emote from the map

engine.Map:displayEmotes (nb_keyframes)

Display the emotes, called by self:display()



Tables

engine.Map.searchOrder
The order of checks for checkAllEntities

Fields:

  • ACTOR
  • TERRAIN
  • PROJECTILE
  • TRAP
  • OBJECT

Fields

engine.Map.zdepth
The map vertical depth storage
engine.Map.TERRAIN
The place of a terrain entity in a map grid
engine.Map.TRAP
The place of a terrain entity in a map grid
engine.Map.ACTOR
The place of an actor entity in a map grid
engine.Map.PROJECTILE
The place of a projectile entity in a map grid
engine.Map.OBJECT
The place of an object entity in a map grid
engine.Map.TRIGGER
The place of a trigger entity in a map grid

Methods

engine.Map:setViewPort (x, y, w, h, tile_w, tile_h, fontname, fontsize, allow_backcolor)
Sets the viewport size Static

Parameters:

  • x screen coordinate where the map will be displayed (this has no impact on the real display). This is used to compute mouse clicks
  • y screen coordinate 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
  • allow_backcolor allow backcolor
engine.Map:enableFBORenderer (shader)
Setup a fbo/shader pair to display map effects If not set this just uses plain quads

Parameters:

  • shader
engine.Map:setBoundedPadding (left, right, top, bottom)
Sets the map viewport padding, for scrolling purposes (defaults to 0) Static

Parameters:

  • left left padding
  • right right padding
  • top top padding
  • bottom bottom padding
engine.Map:setZoom (zoom, tmx, tmy)
Sets zoom level

Parameters:

  • zoom nil to reset to default, otherwise 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)
engine.Map:setObscure (r, g, b, a)
Defines the "obscure" factor of unseen map By default it is 0.6, 0.6, 0.6, 0.6

Parameters:

  • r
  • g
  • b
  • a
engine.Map: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
engine.Map:resetTiles ()
Create the tile repositories
engine.Map:setViewerFaction (faction)
Defines the faction of the person seeing the map Usually this will be the player's faction. If you do not want to use tactical display, dont use it

Parameters:

  • faction
engine.Map:setViewerActor (player)
Defines the actor that sees the map Usually this will be the player. This is used to determine invisibility/...

Parameters:

  • player
engine.Map:init (w, h)
Creates a map

Parameters:

  • w width (in grids)
  • h height (in grids)
engine.Map:save ()
Serialization
engine.Map:regenGridLines ()
Regenetate grid lines definition if it changed
engine.Map:resetDefaultShader ()
Reset default shader
engine.Map: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 and 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
engine.Map:recreate ()
Recreate the internal map using new dimensions
engine.Map:redisplay ()
Redisplays the map, storing seen information
engine.Map: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
engine.Map:cleanFOV ()
Cleans the FOV infos (seens table)
engine.Map: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
engine.Map:call (x, y, pos, e)
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)
  • e the entity to set, if null it will return the current one
engine.Map:remove (x, y, pos, only)
Removes an entity

Parameters:

  • x position
  • y position
  • pos what kind of entity to set(Map.TERRAIN, Map.OBJECT, Map.ACTOR)
  • only only remove if the value was equal to that entity
engine.Map:minimapDisplay (dx, dy, x, y, w, h, transp)
Displays the minimap

Parameters:

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

Returns:

    a surface containing the drawn map
engine.Map:display (x, y, nb_keyframe, always_show, prevfbo)
Displays the map on screen

Parameters:

  • x the coord where to start drawing, if null it uses self.display_x
  • y the coord where to start drawing, if null it uses self.display_y
  • nb_keyframe the number of keyframes elapsed since last draw
  • always_show tell the map code to force display unseed entities as remembered (used for smooth FOV shading)
  • prevfbo previous vertiex buffer object used in last display
engine.Map:zDisplay (z, nb_keyframe, prevfbo)
Called by the engine map draw code for each z-layer

Parameters:

  • z
  • nb_keyframe
  • prevfbo
engine.Map:opaque (x, y)
Sets checks if a grid lets sight pass through Used by FOV code

Parameters:

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

Parameters:

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

Parameters:

  • x
  • y
  • v
engine.Map:applyExtraLite (x, y, v)
Sets a grid as seen, lited and remembered, if it is in the current FOV Used by FOV code

Parameters:

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

Parameters:

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

Parameters:

  • x
  • y
  • v
engine.Map:checkAllEntities (x, y, what)
Check all entities of the grid for a property until it finds one/returns one This will stop at the first entity with the given property (or if the property is a function, the return of the function that is not false/nil). No guaranty is given about the iteration order

Parameters:

  • x position
  • y position
  • what property to check
engine.Map:checkAllEntitiesNoStop (x, y, what)
Check all entities of the grid for a property This will iterate over all entities without stopping. No guaranty is given about the iteration order

Parameters:

  • x position
  • y position
  • what property to check

Returns:

    a table containing all return values, indexed by the entities
engine.Map:checkAllEntitiesLayersNoStop (x, y, what)
Check all entities of the grid for a property This will iterate over all entities without stopping. No guaranty is given about the iteration order

Parameters:

  • x position
  • y position
  • what property to check

Returns:

    a table containing all return values, indexed by a list of {layer, entity}
engine.Map:checkAllEntitiesCount (x, y, what)
Check all entities of the grid for a property, counting the results This will iterate over all entities without stopping. No guaranty is given about the iteration order

Parameters:

  • x position
  • y position
  • what property to check

Returns:

    the number of times the property returned a non false value
engine.Map: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
engine.Map:seeAll (x, y, w, h, v)
See all grids

Parameters:

  • x
  • y
  • w
  • h
  • v
engine.Map:liteAll (x, y, w, h, v)
Lite all grids

Parameters:

  • x
  • y
  • w
  • h
  • v
engine.Map:rememberAll (x, y, w, h, v)
Remember all grids

Parameters:

  • x
  • y
  • w
  • h
  • v
engine.Map:setScroll (x, y)
Sets the current view at a precise location

Parameters:

  • x
  • y
engine.Map:centerViewAround (x, y)
Sets the current view area with the given coords at the center

Parameters:

  • x
  • y
engine.Map:moveViewSurround (x, y, marginx, marginy, ignore_padding)
Sets the current view area if x and y are out of bounds

Parameters:

  • x
  • y
  • marginx
  • marginy
  • ignore_padding
engine.Map:checkMapViewBounded ()
Checks the map is bound to the screen (no "empty space" if the map is big enough)
engine.Map:scrollDir (dir)
Scrolls the map in the given direction

Parameters:

  • dir
engine.Map:getMouseTile (mx, my)
Gets the tile under the mouse

Parameters:

  • mx
  • my if mx < self.displayx or my < self.displayy or mx >= self.display_x + self.viewport.width or my >= self.display_y + self.viewport.height then return end
engine.Map:getTileToScreen (tx, tx, center)
Get the screen position corresponding to a tile

Parameters:

  • tx tile y position
  • tx tile y position
  • center true to return the center of the tile instead of the top/left corner
engine.Map:isBound (x, y)
Checks the given coords to see if they are in bound

Parameters:

  • x
  • y
engine.Map:isOnScreen (x, y)
Checks the given coords to see if they are displayed on screen

Parameters:

  • x
  • y
engine.Map:getScreenUpperCorner ()
Get the screen offset where to start drawing (upper corner)
engine.Map: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
engine.Map:overlay (map, dx, dy, sx, sy, sw, sh)
Import a map into the current one as an overlay, only replacing defined entities

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
engine.Map:addEffect (src, x, y, duration, damtype, dam, radius, dir, angle, overlay, update_fct, selffire, 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 the amount of damage
  • radius the radius of the effect
  • dir the numpad direction of the effect, 5 for a ball effect
  • angle the angle of the effect
  • 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 ....
  • selffire percent chance to damage the source actor (default 100)
  • friendlyfire percent chance to damage friendly actors (default 100)
engine.Map:displayEffects (z, prevfbo, nb_keyframes)
Display the overlay effects, called by self:display()

Parameters:

  • z
  • prevfbo
  • nb_keyframes
engine.Map:processEffects (update_shape_only)
Process the overlay effects, call it from your tick function

Parameters:

  • update_shape_only if true no damage is projected, no duration changes
engine.Map:addObject (x, y, o)
Object functions

Parameters:

  • x
  • y
  • o
engine.Map:particleEmitter (x, y, radius, def, args, shader, zdepth)
Add a new particle emitter

Parameters:

  • x
  • y
  • radius
  • def
  • args
  • shader
  • zdepth
engine.Map:addParticleEmitter (e, x, y)
Adds an existing particle emitter to the map

Parameters:

  • e
  • x
  • y
engine.Map:removeParticleEmitter (e)
Removes a particle emitter from the map

Parameters:

  • e
engine.Map:removeParticleEmitters ()
Now remove all t he ones registered for removal
engine.Map:displayParticles (z, nb_keyframes)
Display the particle emitters, called by self:display()

Parameters:

  • z
  • nb_keyframes
engine.Map:addEmote (e)
Adds an existing emote to the map

Parameters:

  • e
engine.Map:removeEmote (e)
Removes an emote from the map

Parameters:

  • e
engine.Map:displayEmotes (nb_keyframes)
Display the emotes, called by self:display()

Parameters:

  • nb_keyframes
generated by LDoc 1.4.3