• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Lua] How to use SelectUnitSingle()

Status
Not open for further replies.
Level 1
Joined
Apr 8, 2022
Messages
1
Short question: the first code snippet (in JASS) works, but the second one (Lua) does not.

JASS:
function selectPriest takes nothing returns nothing
    call SelectUnitSingle( gg_unit_hmpr_0000 )
endfunction

Lua:
function selectPriest()
    SelectUnitSingle( gg_unit_hmpr_0000 )
end

Why?
 
Level 20
Joined
Jul 10, 2009
Messages
478
I assume you are testing that in different maps, because Jass and Lua don't work in the same map at the same time.

If so, your mistake probably is that you have used the exact same gg-variable, although the numerical suffix (0000 in your case) is map-dependent.
To be sure about the gg-variable name, select the unit via any GUI- action and see what name you get there.
Setting a unit variable is the easiest way to do that.

It's also worth noting that the gg_unit variables only exist after such a GUI- select, at least in Lua- mode (not sure about Jass).
So make sure you do that in both maps before testing your function. ;)
 
Status
Not open for further replies.
Top