Jump to content

Recommended Posts

Posted

I'm working on a mod where I want to create a bunch of spells with script effects. But the scripts would be simpler if they got and set global variables. I don't where I heard this but I heard this might be bad practice or cause issues for the game. I'm not sure if it would so especially since I would name my global variables something that would never conflict with another mod. If anyone could tell me if its fine or if it would indeed cause problems I would greatly appreciate it.

Ps: I'm modding classic Oblivion right now just to clarify. 

Posted

In general programming like C++ and java, global variables are a no-no due to their scope. I've always avoided them for Oblivion as well. I just create a quest that's only purpose is to store all the variables. There's no overhead. In fact it can have a priority of zero. Accessing the variables might even be easier than using a global.

Posted

Most modders avoid them because introducing new globals doesn't bring much benefits over quest or persistent objects variables. If you don't plan to use your mod as a master for others, new defined globals aren't accessible for other mods normaly. Global names are also all together in one list in Construction Set, they are of numeric type only and there are claims that they are much slower to access than other types (quest or script variables). So modders choose method which AndalayBay already mentioned - to define static quest (which doesn't need to be running even) with variables only to serve as a shared databank among all parts as the best.

Posted

I just want to point out that global variables are the only type of variables that can be used in dialogue conditions. Yes, I mean the box in the Dialogue window with a little checkbox on the bottom called "Use Global". There is a no way around that.

In all other situations quest variables are usually preferred.

But a caveat: just how much more complex your scripts will become? If it is only a matter of having to type a longer name, then just type a longer name. But don't avoid globals for the sake of avoiding globals. Oblivion scripting is NOT like C++, it is more like Fortran, and globals are an integral part of it. They have their uses and their place. You have to evaluate each case individually, there is no blanket solution, or indeed a blanket ban on globals!

  • 100% 1
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...