Storyboard external module error

Can anyone tell me what is wrong with this picture? I’m trying to clean up the storyboard scene by moving code into external modules, trees.lua in this example. Calling a function in trees.lua within createScene works just fine, but calling any function in trees.lua or any other module from enterScene or an enterFrame event returns a runtime error: “attempt to call field ‘plantTree’ (a nil value).”

I need to be able to call functions in modules during enterFrame events within storyboard scenes.

  
local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
  
---------------------------------------------------------------------------------  
-- BEGINNING OF YOUR IMPLEMENTATION  
---------------------------------------------------------------------------------  
  
local trees = require "trees.lua"  
  
-- Called when the scene's view does not exist:  
function scene:createScene( event )  
 local group = self.view  
  
 trees.plantTree() \<  
end  
  
-- Called immediately after scene has moved onscreen:  
function scene:enterScene( event )  
 local group = self.view  
  
 local function gameLoop(event)  
 trees.plantTree() \< end  
  
 Runtime:addEventListener("enterFrame", gameLoop)  
end  
  
-- Called when scene is about to move offscreen:  
function scene:exitScene( event )  
 local group = self.view  
  
end  
  
-- Called prior to the removal of scene's "view" (display group)  
function scene:destroyScene( event )  
 local group = self.view  
  
end  
  
---------------------------------------------------------------------------------  
-- END OF YOUR IMPLEMENTATION  
---------------------------------------------------------------------------------  
  
-- "createScene" event is dispatched if scene's view does not exist  
scene:addEventListener( "createScene", scene )  
  
-- "enterScene" event is dispatched whenever scene transition has finished  
scene:addEventListener( "enterScene", scene )  
  
-- "exitScene" event is dispatched before next scene's transition begins  
scene:addEventListener( "exitScene", scene )  
  
-- "destroyScene" event is dispatched before view is unloaded, which can be  
-- automatically unloaded in low memory situations, or explicitly via a call to  
-- storyboard.purgeScene() or storyboard.removeScene().  
scene:addEventListener( "destroyScene", scene )  
  
---------------------------------------------------------------------------------  
  
return scene  

I originally had the enterFrame event outside of enterScene, but trees.plantTree still returned the same runtime error. [import]uid: 99903 topic_id: 23546 reply_id: 323546[/import]

Have you found a solution to that problem? I’m getting a similar error. [import]uid: 105206 topic_id: 23546 reply_id: 114306[/import]

Have you found a solution to that problem? I’m getting a similar error. [import]uid: 105206 topic_id: 23546 reply_id: 114307[/import]

It’s hard to tell for sure without seeing your trees.lua.

But I am doing something similar like this

local oSQL = require(“sqliteinterface”)

Larry [import]uid: 11860 topic_id: 23546 reply_id: 114408[/import]