lua-users home
lua-l archive

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


Thanks a bunch.

Try 'MainState:addCamera(T)'.

worked, the function now has camera in it and it is not null, thanks!

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

>>This creates and immediately throws away a table, is that the intention?

You are correct, here is a different example of my FreeCamera object which attempts to inherit the Camera object

local require = require
local _G = _G

module(...)

require "Core.Camera.Camera"

local M = _G.Class( _G.Core.Camera.Camera ) --Gross, lame
FreeCamera = M

function M:__constructor(x,y,z)
self.Active = false
    self.x = x
    self.y = y
    self.z = z
    self.ID = _G.EngineManager:getCamera()
    --_G.print("got Id of:" .. self.ID)
    self:setCameraPosition(x, y, z, self.ID)
    _G.print("<<<Camera in lua>>>")
end

function M:Move(x,y,z) 
_G.EngineManager:MoveCam()
end

function M:setCameraPosition(x,y,z,ID) 
_G.EngineManager:SetCameraPosition(x,y,z,ID)
end

function M:lookAt(ID)
    _G.EngineManager:lookAt(ID)
end

function M:setActive(ID)
self.Active = true
NonActiveID = _G.EngineManager:SetActiveCamera(ID)
_G.EM:FireEvent("CameraNotActive" , NonActiveID)
    --EngineManager:SetActiveCamera(ID)
end

I tried using a class implementation to pull out common functionality (Class impl gotten from the event system in lua programming gems). That combined with my attempted use of modules makes it appear to not be working.

-J




On Wed, Feb 10, 2010 at 10:47 PM, Etan Reisner <deryni@unreliablesource.net> wrote:
On Wed, Feb 10, 2010 at 10:31:02PM -0800, Joe Andresen wrote:
<snip>

> MainState.addCamera(T)

Try 'MainState:addCamera(T)'.

<snip>

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

This creates and immediately throws away a table, is that the intention?

<snip>

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

This creates a function which expects two arguments, self and camera. Your
call only passes one. Check "self" you'll see it is your camera.

> thanks for any help!
> -Joe

   -Etan