[Resolved] Scope Troubleshooting with nested lua files...

Tough one to explain, but basically: I can successfully call a function if I call it directly. But if I call it indirectly, it doesn’t appear on-screen and has an x-value of around -2million.

It’s going to be difficult to make sample code, but here’s the basic gist:

  1. I’m using modular classes. So I would, say, build the object in here:

[code]–object.lua
– imagine the metatable stuff here. “object” has a table, and object.vis = display.newGroup()

function object:build() – pretty simple; make a display object and insert it into the above display.
local object = display.newRect(0,0,32,32)
self.vis:insert(object)
end[/code]

[code]–building.lua
– again, imagine metatable stuff here. “building” has a table, and building.data = {}

function building:setup()
for i = 1, 3 do
local newbox = object:new() – calls the object constructor.
table.insert(self.data, newbox) – newbox is a regular table, so we insert it that way.
end
end

function building:buildsomething(index) – a passthrough to call object:build()
self.data[index]:build()
end[/code]

^ This shortcut above tells the object (nested into building.data) to create a display object. The end result of all of this?

-- main.lua theBuilding:build(1) -- seems to work but the object isn't visible, reporting: --x=0,y=0,contentBounds.xMin=-2million theBuilding.data[1]:build() -- works perfectly

(And yes, if I set the display object to it’s current position + the 2 million…it shows up onscreen.)

Any ideas? I’ve heard of seeing such crazy pixel reports when you try to mess with an empty display group, but a) see above and b)It does have contents when I use .numChildren. [import]uid: 41884 topic_id: 23084 reply_id: 323084[/import]

Bleh. Resolved. It was exactly the empty display group.x/y error, just set in an obtuse sort of way…

>_< [import]uid: 41884 topic_id: 23084 reply_id: 92396[/import]