General Questions

The reason that I am asking these questions is because I am getting a “Module Name Conflict Error” when coming back to the same scene!

main.lua -> options.lua -> sns.lua -> options.lua -> sns.lua --error happens here! Error is Listed at the bottom…

-Do you have to insert variables into the localGroup?
example:

 local numTimesHit = 0  
 localGroup:insert(numTimesHit)  
  

-Can we use and assign Global variables?
-When using Global Variables do I need to remove it before proceeding to the next scene?
-Do we have to assign it to the localGroup?
example:

 \_G["globalVariable"] = 789  
localGroup:insert(\_G["globalVariable"])  

Do we have to remove eventListeners and timers before switching scenes?

Runtime error .../Desktop/LC/CTF/game4/sns.lua:1: name conflict for module 'sns' stack traceback: [C]: ? [C]: in function 'module' .../Desktop/LC/CTF/game4/sns.lua:1: in main chunk [C]: in function 'require' ...top/LC/CTF/game4/director.lua:116: in function 'loadScene' ...top/LC/CTF/game4/director.lua:175: in function 'changeScene' ...LC/CTF/game4/playerSelection.lua:35: in function <...lc><br> ?: in function <?:214><br><br> [import]uid: 7197 topic_id: 5160 reply_id: 305160[/import] </…lc>

Ricardo I removed all eventListeners and I still get the error!

And I can’t add global variables to localGroup, so that would not be the reason either.

What about local variables, do they need to be added or is it just images?
local numTimesHit = 0
localGroup:insert(numTimesHit) [import]uid: 7197 topic_id: 5160 reply_id: 17178[/import]

I think I isolated the problem. Do you think this is the reason? Nothing else gives an error. It works perfectly if I comment out the use of this file. The only difference that this file has images with extra properties!
example:
box1b.timesHit = 0
collisionType, timesHit, points, hitable image properties is the problem!!!

sns.lua

local sticksAndStones = require("sticksAndStones")  
  
 local hbLeft, box1b, box2b, box3b, stone1b, stone2b, stone3b, stone4b, wood1ab, wood1bb, wood1cb, wood1db, wood2hab, wood2hbb, wood2vab, wood2vbb, wood3hb, wood3vb, wood4hb, wood4vb, wood5b, woodstub1b, woodstub2hb, woodstub2vb, box1a, aox2a, box3a, stone1a, stone2a, stone3a, stone4a, wood1aa, wood1ba, wood1ca, wood1da, wood2haa, wood2hba, wood2vaa, wood2vba, wood3ha, wood3va, wood4ha, wood4va, wood5a, woodstub1a, woodstub2ha, woodstub2va = sns()  
 localGroup:insert(hbLeft)  
 localGroup:insert(box1b)  
 localGroup:insert(box2b)  
--more images are inserted here!  
  
-------------------------------------------------------------------  

sticks.lua

function sns()  
 box1b = display.newImage("images/box1.png", 426, 93)   
 box1b.collisionType = "parts"  
 box1b.timesHit = 0  
 box1b.points = 100  
 box1b.hitable = 5  
  
-- more images are from here!  
  
 return hbLeft, box1b, box2b, box3b, stone1b, stone2b, stone3b, stone4b, wood1ab, wood1bb, wood1cb, wood1db, wood2hab, wood2hbb, wood2vab, wood2vbb, wood3hb, wood3vb, wood4hb, wood4vb, wood5b, woodstub1b, woodstub2hb, woodstub2vb, box1a, aox2a, box3a, stone1a, stone2a, stone3a, stone4a, wood1aa, wood1ba, wood1ca, wood1da, wood2haa, wood2hba, wood2vaa, wood2vba, wood3ha, wood3va, wood4ha, wood4va, wood5a, woodstub1a, woodstub2ha, woodstub2va  
end  
--------------------------------------------------------------------  

I need these properties to perform the game what is a work around?

Thank you Jason
[import]uid: 7197 topic_id: 5160 reply_id: 17340[/import]

@derwydd

Try to never use the same name for different functions and/or files. For best practices, put same letter or word before the name to identify which you’re calling. If you really need the exactly same name, use it as a method, like this:

sticks.lua

function sticks:sns ()  
 ...  
end  

sns.lua

myVar = sticks:sns() [import]uid: 8556 topic_id: 5160 reply_id: 17399[/import]