The Namespace Folly [Renamed]

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

The Namespace Folly [Renamed]

Post by NutJob »

Hello, before I started the Grimrock II. editor up a spent a few days perusing the LoG1 modding forums to get a handle on how things were, generally, done in that one. There wasn't much information, yet, on these forums so while learning I misinterpreted the keyword global. I thought, coming into LoG2 modding, it meant it was truly global so I decided I would like all my functions within it's own namespace (not that there's true namespace functionality with LUA but that's besides the point) so I wouldn't have name-collision problems with other modders.

Cut to the chase, a few days later I discover variables are only global to that script entity (which is, around, a couple weeks ago now) and I really don't need to bother with a namespace anymore but now I have all my functions wrapped up in a table, like so:

Code: Select all

GFX = {}
GFX.functionA = function() end
GFX.functionB = function() end
-- so on
Is it bad to have these functions assigned to a global table? So far I've had no problems with saves *directly related to having functions in my GFX namespace" but are there risks down the road to doing it like this?

((Yes I had crashes due to saving returned entities to globally available variables but have squashed this problem.))
Last edited by NutJob on Wed Nov 05, 2014 5:17 pm, edited 1 time in total.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Let me get this straight, is this bad?

Post by petri »

It works but I would say it unnecessarily complicates code and makes it more inefficient (the extra GFX table lookups cost time).
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Let me get this straight, is this bad?

Post by NutJob »

petri wrote:It works but I would say it unnecessarily complicates code and makes it more inefficient (the extra GFX table lookups cost time).
Slowly becoming aware of that now ~laughs~... I just thought I was going to be competing with other modders for function_names because of my misinterpretation of what global meant. Thanks for the reply.
Post Reply