• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Lua] How to make globals throughout script?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

For using LUA scripts, I have to use the blocks like this:
JASS:
//! externalblock extension=lua ObjectMerger $FILENAME$
...
//! endexternalblock

But how can I make a global variable in one block which exists in all the other separate blocks? Kind of like global variables in JASS--once you declare it, all other triggers can see it.

So basically I'd like to have this

Block of Globals

JASS:
//! externalblock extension=lua ObjectMerger $FILENAME$
//My list of global variables
//! endexternalblock

Block of unit objects (separate trigger)

Block of item objects

etc..

All on separate triggers to make code readable (my units object code is already many many pages long >_>, I don't want to put another 10,000 lines of code for items just to use some constants that I calculated from units).
 
Each external block is its own script, they all run separately. As such, these scripts can't see each other at all.

My suggestion is to actually write .lua files and then do a //! import into the external block. Alternatively, you can actually run the exes outside of WE. You can pass in the map and everything ;).

The Lua framework I wrote installs scripts on to the machine via other Lua and then runs those scripts with dofile (all within the same block). Check my resources in my sig under the Lua folder.
 
Status
Not open for further replies.
Top