Jass globals in textmacro's (lua)

dudeim

New Member
Reaction score
22
Hey,

I'm currently bussy with textmacro's and I wanted to know how you can use a jass global inside a textmacro like this:

JASS:

globals 

integer TestGlobal = 1

endglobals

//! textmacro TestGlobals //dunno if this is how it calls but just think it is correct<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
//! textmacroextend extend lua = blabla whatever goes here // no WE open so dunno the correct names
//! i TestGlobal = 5 //now the global I created above should be 5 is this the correct way?
//! endextendedtextmacro
//! endtextmacro


So would this work?

Thanks
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
You can't access JASS globals through lua. (as lua is ran during compilation, not ingame) However, you can create your own variables in lua, as such:
JASS:
//! i lulu = 5 -- this is a global variable
//!i i local luluz = &quot;hi&quot; -- this is a local variable
 

dudeim

New Member
Reaction score
22
Ok but can I later set the lua variable to a jass global? Or in anyother way acces the global anytime I want later in a diffrent function (that can be called whenever I want it to)?
 

dudeim

New Member
Reaction score
22
Hmm well I'm currently creating 5 abilities which need to go into a global array so that I can switch the abilities out. So how would I go do that then?
 

Dirac

22710180
Reaction score
147
Please be more specific about your idea, you can always switch what the abilities do through triggers adding and removing conditions.
 

dudeim

New Member
Reaction score
22
No thats not what I mean I want to switch them on the unit's command board.
 

Nestharus

o-o
Reaction score
84
Well, I was going to say that if you were generating 5 abilities dynamically via Lua, there is a way to get those dynamic ids to the JASS script via Lua. This is better than hard coding as it allows dynamism.
 

dudeim

New Member
Reaction score
22
Well it's a system for personal use and the id's used are not common so it will work this way thanks for posting though;)
 

Nestharus

o-o
Reaction score
84
Ok then, well for future reference.


If you are using Lua object creation stuff, then it auto imports the variable you assign to the object.


For LUA_FILE_HEADER, there is a writejass function that allows you to write jass script, meaning that you can write a JASS variable with the id in it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top