• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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?
 
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