Module.new()

   
Type function
Library wattageTileEngine.Module.*
Return value Module
Keywords  
See also  

Overview

This function creates a new instance of type Module.

Syntax

Module.new( params )
params (required)

Table. Contains all required inputs. See Required Properties below.

Required Properties

The params table contains the following properties:

name (required)

String. Name of the module.

rows (required)

Number. Number of rows in the module.

columns (required)

Number. Number of columns in the module.

lightingModel (required)

LightingModel. LightingModel for the module.

losModel (required)

LineOfSightModel. LineOfSightModel for the module.

Examples

local TileEngine = require "plugin.wattageTileEngine"

-- Callback to indicate whether a tile is transparent
local function isTransparent(column, row)
    -- Make an opaque wall along column 5
    return column ~= 5
end

-- Callback to indicate whether a tile is affected by ambient lighting.
local function isTileAffectedByAmbient(row, column)
    -- Make all tiles affected by ambient lighting
    return true
end

local lightingModel = TileEngine.LightingModel.new({
    isTransparent = isTransparent,
    isTileAffectedByAmbient = isTileAffectedByAmbient,
    useTransitioners = true
})

local lineOfSightModel = TileEngine.LineOfSightModel.new({
    radius = 15,
    isTransparent = isTransparent
})

local myModule = TileEngine.Module.new({
    name = "myModule",
    rows = 100,
    columns = 100,
    lightingModel = lightingModel,
    losModel = lineOfSightModel
})