Where to put global variables?

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Where to put global variables?

Post by Gambit37 »

I've put some file path variables in my startup.lua so that I can use them anywhere to reference my resources folders, eg:

Code: Select all

pathimg = "../../../project/_rtc/_files/_img/"
pathsfx = "../../../project/_rtc/_files/_sfx/"
pathmus = "../../../project/_rtc/_files/_mus/"
However, now ESB complains when I open the dungeon file that these variables are empty:

Code: Select all

attempt to concatenate global 'pathimg' (a nil value)
How and where should I declare global variables like this so they work in both DSB and ESB?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Where to put global variables?

Post by Sophia »

This should work. Something else must be going wrong.

Which file are you trying to use the paths in, and where?
Can you paste the code that tries to do it?
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Where to put global variables?

Post by Gambit37 »

I have a small lua file to code up an orc, called orc.lua which is read in my objects.lua with dsb_import_arch("orc.lua", "orc"). This is what DSB chokes on --it's fine if I also add my path variables to the orc.lua file though, but that rather defeats the point of globals... ;-)
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Where to put global variables?

Post by Sophia »

Ok, I'll fix that.
Post Reply