TriggerSleepAction() breaking Filter()?

Matrixboy

New Member
Reaction score
1
Hey there everyone!

I'm working on this one code, that would round up all the units owned by a single, and to kill them. This will be used when people leave, are kicked, etc. etc. I also have it running at Initialization, in-case slots aren't open. I have it display text that the player has left, or was never present, ping them, and then (should) wait 120.00 seconds and kill them.

This is what I currently have:

JASS:
library Funcs
    function remove takes nothing returns boolean
        local unit character = GetFilterUnit()
        local string name = GetUnitName(character)
        local integer y = 0
        call PingMinimap (GetUnitX(character), GetUnitY(character), 2.00)
        loop
            exitwhen y == 11
                call DisplayTextToPlayer(Player(y), 0.0, 0.0, "The owner of " + name + " has left the game.  His idle character has been pinged, and " + name + " will drop his items in 120 seconds, and die.")
                set y = y+1
        endloop
        call TriggerSleepAction(120.00)
        call KillUnit( character )
        set character = null
        return true
    endfunction
endlibrary


JASS:
function check_empty takes nothing returns nothing
    local group KillGroup = CreateGroup()
    local integer x = 0
    call TriggerSleepAction(0.00)

    loop
        exitwhen x==11
            if ( GetPlayerSlotState(Player(x)) != PLAYER_SLOT_STATE_PLAYING ) then
                call GroupEnumUnitsOfPlayer(KillGroup, Player(x), Filter(function remove))
            endif
            set x = x+1
    endloop
    set x = 0
    call DestroyGroup(KillGroup)
    set KillGroup = null
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
    set gg_trg_Init = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Init, function check_empty )
endfunction


The only thing is, in the function remove, it seems to freeze at the TriggerSleepAction() call. After the alloted time, no character is killed. I've also done a test with simply printing text after the sleep, still to no avail. If I remove the call, it will work perfectly fine. But I really do wish to have the break between it, as to create a little interesting challenge for the corpses' items.

Would anyone know why it's doing this to me? I have a guess that it may have to be using it as the Filter in GroupEnumUnitsOfPlayer(), but have no way to test this (in all honesty, I don't know how any of the *Enum*() triggers work at all, so wouldn't know how to rewrite what I did. I posted here previously and someone graciously helped me out, however was unaware that I planned on adding the TriggerSleepAction() in. ).
 

Builder Bob

Live free or don't
Reaction score
249
I'm a little confused.

The only thing is, in the function remove, it seems to freeze at the TriggerSleepAction() call
Here you say there's a TriggerSleepAction() call in the function remove. In the code you posted the TriggerSleepAction() call is in the check_empty function.

As far as I can see the TriggerSleepAction() in the check_empty should not cause any problems.
However, if you tried using TriggerSleepAction() in the function remove, it would stop responding the way you describe it. This is because TriggerSleepAction() can only be used in Action functions. Not condition functions. Condition functions includes boolexpr, filter and conditionfunc.

If what you wrote was a typo, then I don't know what the problem is.
 

Matrixboy

New Member
Reaction score
1
I'm a little confused.


Here you say there's a TriggerSleepAction() call in the function remove. In the code you posted the TriggerSleepAction() call is in the check_empty function.

As far as I can see the TriggerSleepAction() in the check_empty should not cause any problems.
However, if you tried using TriggerSleepAction() in the function remove, it would stop responding the way you describe it. This is because TriggerSleepAction() can only be used in Action functions. Not condition functions. Condition functions includes boolexpr, filter and conditionfunc.

If what you wrote was a typo, then I don't know what the problem is.

Eek! Thank you for pointing that out. I did have TriggerSleepAction() in the function remove, however I posted the code I was testing (to see if it would work without it).

And thank you for explaining that it wouldn't work within Filter. That must have been why it wasn't working. Do you know of any way I can achieve what I'm attempting without filter? I never knew exactly what GroupEnum did anyways. Should I maybe make KillGroup a global, and pass all of the units owned by the missing player into that group?
 

Builder Bob

Live free or don't
Reaction score
249
Since you're using a library, I can see you have JassHelper. That will make solving this problem very simple.

Use this:
JASS:
library Funcs
    
    private function Enum takes nothing returns nothing
        local unit character = GetFilterUnit()
        local string name = GetUnitName(character)
        local integer y = 0
        call PingMinimap (GetUnitX(character), GetUnitY(character), 2.00)
        loop
            exitwhen y == 11
                call DisplayTextToPlayer(Player(y), 0.0, 0.0, "The owner of " + name + " has left the game.  His idle character has been pinged, and " + name + " will drop his items in 120 seconds, and die.")
                set y = y+1
        endloop
        call TriggerSleepAction(120.00)
        call KillUnit( character )
        set character = null
    endfunction
    
    function remove takes nothing returns boolean
        call Enum.execute()
        return true
    endfunction
endlibrary


By adding the extension .execute to a function call you can simulates an action function to allow you to use TriggerSleepAction().


Btw: You should start privatizing your functions (like I've done with the function Enum) so you can use the same function names in different scopes and libraries.
 

Matrixboy

New Member
Reaction score
1
Since you're using a library, I can see you have JassHelper. That will make solving this problem very simple.

Use this:
JASS:
....


By adding the extension .execute to a function call you can simulates an action function to allow you to use TriggerSleepAction().


Btw: You should start privatizing your functions (like I've done with the function Enum) so you can use the same function names in different scopes and libraries.

Thank you for all of your help! It works perfect now, thank you.

The .execute, that is working with it-as an object, correct? I was reading through the vjass manual, but most of it went right over my head. I never even noticed anything similar to what it said, and how you explained it. (I went back now, and did notice it mentioning something about execute, but in a lot more formal terms than you put it). Thanks for your explanation of it, made it a lot easier! I guess I'll have to go through and rad that manual again, if it'll help me avoid problems that make me bash my head against the wall.

Thanks, I just started putting everything into scopes, and privatizing things that I know won't be used outside of that library/scope. :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top