IsUnitSelected

TheOverWhelm

Member
Reaction score
16
Does IsUnitSelected even work? I tried it in the RPing map I've been developing and it doesn't seem to do its job, ever.
Trigger:
  • Custom script: if IsUnitSelected(GetEnumUnit(),Player(bj_forLoopAIndex))==true then
    • Unit Group - Remove (Picked unit) from SelectedUnits[(Integer A)]
    • Custom script: endif

This doesn't even remove them from the group. I've tried it with ==false as well but it still didn't work. I know the loop is working (messages, other conditions/actions too) so I have no idea what's wrong.
 

TheOverWhelm

Member
Reaction score
16
Trigger:
  • Events
    • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in SelectedUnits[AInt]) Not equal to (!=) 0
            • Then - Actions
              • Unit Group - Pick every unit in SelectedUnits[(Integer A)] and do (Actions)
                • Loop - Actions
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Multiple ConditionsOr - Any (Conditions) are true
                        • Conditions
                          • (Owner of (Picked unit)) Equal to (==) Neutral Hostile
                          • (Owner of (Picked unit)) Equal to (==) Neutral Passive
                          • ((Owner of (Picked unit)) slot status) Equal to (==) Has left the game
                          • ((Owner of (Picked unit)) slot status) Equal to (==) Is unused
                          • (Owner of (Picked unit)) Equal to (==) (Player((Integer A)))
                    • Then - Actions
                    • Else - Actions
                      • Unit Group - Remove (Picked unit) from SelectedUnits[(Integer A)]
                  • Custom script: if IsUnitSelected(GetEnumUnit(),Player(bj_forLoopAIndex))==true then
                  • Unit Group - Remove (Picked unit) from SelectedUnits[(Integer A)]
                  • Custom script: endif
            • Else - Actions
 

Bribe

vJass errors are legion
Reaction score
67
Post it in JASS, this is not the GUI forum. And also post the trigger that adds units to SelectedUnits (in JASS, of course).
 

TheOverWhelm

Member
Reaction score
16
The question I asked involved that, and there is JASS in there so it involves JASS and belongs in the JASS forum, nonetheless, here's the periodic trigger in JASS.
JASS:
function Trig_OtherSelectionSet2Periodic_Func001Func001Func001Func001Func002C takes nothing returns boolean
    if ( ( GetOwningPlayer(GetEnumUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetEnumUnit()) == Player(PLAYER_NEUTRAL_PASSIVE) ) ) then
        return true
    endif
    if ( ( GetPlayerSlotState(GetOwningPlayer(GetEnumUnit())) == PLAYER_SLOT_STATE_LEFT ) ) then
        return true
    endif
    if ( ( GetPlayerSlotState(GetOwningPlayer(GetEnumUnit())) == PLAYER_SLOT_STATE_EMPTY ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetEnumUnit()) == ConvertedPlayer(GetForLoopIndexA()) ) ) then
        return true
    endif
    return false
endfunction

function Trig_OtherSelectionSet2Periodic_Func001Func001Func001Func001C takes nothing returns boolean
    if ( not Trig_OtherSelectionSet2Periodic_Func001Func001Func001Func001Func002C() ) then
        return false
    endif
    return true
endfunction

function Trig_OtherSelectionSet2Periodic_Func001Func001Func001A takes nothing returns nothing
    if ( Trig_OtherSelectionSet2Periodic_Func001Func001Func001Func001C() ) then
    else
        call GroupRemoveUnitSimple( GetEnumUnit(), udg_SelectedUnits[GetForLoopIndexA()] )
    endif
endfunction

function Trig_OtherSelectionSet2Periodic_Func001Func001C takes nothing returns boolean
    if ( not ( CountUnitsInGroup(udg_SelectedUnits[udg_AInt]) != 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_OtherSelectionSet2Periodic_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 12
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( Trig_OtherSelectionSet2Periodic_Func001Func001C() ) then
            call ForGroupBJ( udg_SelectedUnits[GetForLoopIndexA()], function Trig_OtherSelectionSet2Periodic_Func001Func001Func001A )
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_OtherSelectionSet2Periodic takes nothing returns nothing
    set gg_trg_OtherSelectionSet2Periodic = CreateTrigger(  )
    call DisableTrigger( gg_trg_OtherSelectionSet2Periodic )
    call TriggerRegisterTimerEventPeriodic( gg_trg_OtherSelectionSet2Periodic, 1.00 )
    call TriggerAddAction( gg_trg_OtherSelectionSet2Periodic, function Trig_OtherSelectionSet2Periodic_Actions )
endfunction

The trigger that adds works perfectly.
 

Bribe

vJass errors are legion
Reaction score
67
Well, most JASS-ers (maybe all but one or two) have a much easier time looking at actual script, not GUI nor a corrupted demonchild of GUI and JASS.

Your first problem (if it's not intentional) you are using SelectedUnits[AInt] within the loop - don't you mean to use Integer A instead, because AInt is found only in this one place.

I will take a look around to see if I can find more.

1. You don't need to check if the group is empty before that "pick every unit". If the group is empty, nothing will happen, so there's no problem :)
 

TheOverWhelm

Member
Reaction score
16
I'm one of those few, then.
It was not intentional, fixed nonetheless.
The reason I check it is because checking something instead of performing a "nothing" is faster.
Err, I think I see it. I should add +1 to the Playernumber, since Player1 in GUI is not == Player1 in JASS.
 

Bribe

vJass errors are legion
Reaction score
67
It is not faster, because in "checking" it you're running the Jass "ForGroup" (count units in group) and in not checking it you're using "ForGroup" yet again. If you take out the "Is Group Empty" you will be running with higher efficiency & speed.

You're obviously not "one of those few" because you wrote this in GUI, not JASS, though I'm not going to get started on that so forget it.

Yes, now that I see that Player number thing, you should do:

Trigger:
  • Custom script: if IsUnitSelected(GetEnumUnit(),Player(bj_forLoopAIndex - 1)) then


You never need == true, that's just some nonsense GUI throws in. You also don't need == false, you just type "not" before the statement, like this:

JASS:
if not (check) or not (other check) then


It's faster to type & you can do more tricks with the "not" command.
 

Jedi

New Member
Reaction score
63
GUI has that condition.Under boolean comparasions, Unit - Unit Selected By Player.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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