HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Constant Problem

05-14-2007, 06:09 PM#1
Silvenon
Can I put this in the map header:

Collapse JASS:
globals
constant unit u = gg_unit_U001_0000 //A unit that's already on the map
endglobals

and then using it in triggers so I don't have to write gg_unit_U001_0000 all the time? Or if that doesn't work, is there a way to do it?

EDIT: It works for strings, but I don't think it works for units
05-14-2007, 06:23 PM#2
SFilip
You can use a preprocessor (JassHelper, though you might want to see newgen instead) and make that possible. The preprocessor can move your global declarations to the globals block at the beginning of the script which is the only place you can actually define them.
The alternate solution, what a lot of people do, would be something like
Collapse JASS:
constant function myunit takes nothing returns unit
    return gg_unit_U001_0000
endfunction
This way you can simply use myunit() instead of gg_unit_U001_0000. In addition Vexorian's map optimizer will replace (inline) these myunit()s with gg_unit_U001_0000 to make the execution faster.
05-15-2007, 05:43 AM#3
Silvenon
Thanks a lot, I think I'll use the alternate method (but I have JassNewGenPack)

Why does it work for strings and not for units?