Globals ?

Okay I do not get it, I understand they do not want us to use _G for globals, so I followed the tutorial and did this. 

in a new Class called myData.lua

local M {}

local initialNumEnemiesOnStage = 5

return M

Then in my levelOne scene I called 

local myData =  require(“myData”)

 ( I get an error Attempt to compare number with nil )

if enemieCount < myData.initialNumEnemiesOnStage then

tmr = timer.performWithDelay(1000,addEnemy)

  else

    timer.performWithDelay (5000,removeEnemy)

      timer.cancel(tmr)

      end

end 

Any Help is Appreciated.

JZ 

It needs to be:

M = {}

Also, your local variable isn’t going to be able to be accessed anywhere without associating it with the global table. You might want:

M.sampleVar = 5

Got it !! Great thanks much, 

So to declare variables in the global use the container definition M instead of local.

Worked perfectly 

JZ 

It needs to be:

M = {}

Also, your local variable isn’t going to be able to be accessed anywhere without associating it with the global table. You might want:

M.sampleVar = 5

Got it !! Great thanks much, 

So to declare variables in the global use the container definition M instead of local.

Worked perfectly 

JZ