lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

i have a script that uses a couple modules.

require "Core.Camera.FreeCamera"
require "Core.GameState"

MainState = Core.GameState.GameState()

local T = Core.Camera.FreeCamera.FreeCamera(0,0,-35)


c = T.getObjectType()
print(c .." No worries" )

Camera works fine, but GameState is suspect.... when i pass the camera (T) into the function addCamera and step in it with the debugger, it becomes nil.

Is there something about environments in modules that i am missing?

here is what the gamestate module looks like.

local _G = _G

local M = {}
M = _G.Class()
GameState = M

function M:__constructor()
    -- Array of Cameras, 0 is default?
    self.Cameras = {}


-- the following are getters and adders for the respective objects stored by the game state

function M:getCamera(id)
    return self.Cameras[id]

function M:addCamera(camera) --this is nil.. what the heck?
    self.Cameras[camera.getID()] = camera

thanks for any help!