Globals and Modules?

Defining a Global in my main.lua file:

\_G["Level"] = 1  
\_G["levelSeries"] = 2  

Then I edit this in my level select module: (which works)

Level = event.target.tag  
print("current level == " .. Level)  

Then use this edited information in my game logic file:

print("Level")  

Can anyone tell me why Level is printed as 1?
Why is this happening and how do I get around it?

Thanks,

Lewis.
[import]uid: 87611 topic_id: 14505 reply_id: 314505[/import]

You’ve set it as 1, but I’m guessing [lua]Level = event.target.tag[/lua] is intended to change that value?

If so, you really need to show some code so we can work out why it isn’t changing as you’d like.

Peach :slight_smile: [import]uid: 52491 topic_id: 14505 reply_id: 53728[/import]

It’s changing the value though, as I’m printing it after, and it shows the new value. It’s just when it goes to the game logic module it says it’s one when it should be the value I changed it to? [import]uid: 87611 topic_id: 14505 reply_id: 53739[/import]

Apparently to set a global you need to use _G. but to retrieve it just the name, so it’s sorted now. [import]uid: 87611 topic_id: 14505 reply_id: 53743[/import]