conditional wait minimum cooldown

Xbing

New Member
Reaction score
0
this is just a very basic general question, and although i have spent a little bit of effort searching for a thread on this topic, i only got 1 relevant thread with the keywords "minimum interval check condition", and though the thread does provide some possible answers, it does not totally answer my doubts.

i want to have a wait loop that waits for a condition to be true. it is now this:
Code:
          loop
                exitwhen ( Minigame_End_Check() )
                call TriggerSleepAction(2.00)
            endloop

it is not giving any problems yet as the interval between checking is 2 seconds. however, i noticed that in GUI world editor, the limit is 0.10 seconds, and it will not go below. even when it is converted to JASS whatever value entered will be compared to bj_WAIT_FOR_COND_MIN_INTERVAL which is 0.10 seconds and any value below will be ignored and the value of 0.10 will be used instead. *edit: Minigame_End_Check() is actually just a function that checks for a boolean that is going to be manually set to true when my "minigame" has ended.

so the question is:
if i want a more precise check (something like 0.01 seconds), i know it is a bad practice, will there be anything wrong(bugs etc.) with
Code:
          loop
                exitwhen ( Minigame_End_Check() )
                call TriggerSleepAction(0.01)
            endloop
i have tried testing this, it worked fine but i am doubtful of how clean it is, will it cause any internal errors or what?
 

Ayanami

칼리
Reaction score
288
Instead of using [ljass]TriggerSleepAction[/ljass], you could use a timer. A timer can go low as till 0 seconds interval.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
TSA's (Waits) are usually bad, timers are better.
But in any case, 0.01 is inaccurate in TSA's, they're almost always off IIRC.
 

Xbing

New Member
Reaction score
0
so timers are much more accurate than TSAs, and to apply it in this case i have to start a timer, then catch it with the exitwhen statement? so now i will need to check for 2 conditions, whether the timer is up, and whether the actual condition is true. Is that the implementation you have in mind?

thanks alot anyways.
 

Dirac

22710180
Reaction score
147
Hold on Xbing. The method you're using to "check if conditions are true" is the SAME as TSA, it's a BJ with a loop that cointains a TSA. You can add functions to timers when they end
JASS:
call TimerStart(timer,real wait,periodic boolean,function yourfunction)

example
JASS:
call TimerStart(MyTimer,10.,false,function endminigame)
 

tooltiperror

Super Moderator
Reaction score
231
TSA does not contain TSA in it, because TSA is not a BJ, it is a native, the good twin of BJs.
 

Dirac

22710180
Reaction score
147
What i meant is that he was using the Wait for condition action, isn't that a nasty BJ?
 

Sevion

The DIY Ninja
Reaction score
413
Why not something simple like this?

JASS:
function callback takes nothing returns nothing
    if ( theCondition == true ) then
        call endTheWait() // Or do it directly here
        call PauseTimer(GetExpiredTimer())
        call DestroyTimer(GetExpiredTimer())
    endif
endfunction

// Some other function
    call TimerStart(CreateTimer(), 0.0325, true, function callback)


I'm not so sure there's really truly any other way (that's not ugly and inefficient).

TSA would probably have to be used and that's no fun to use.
 

Bribe

vJass errors are legion
Reaction score
67
Rather than waiting until Minigame_End_Check is true,
there could very well be an event that you could spin
this off of. For example, if you're waiting until a unit
has life of 50%, there are events that can detect this
sort of thing.

You can really help us to help you if you tell us what
the Minigame_End_Check function is doing.
 

Xbing

New Member
Reaction score
0
i have updated the first post with what Minigame_End_Check does. i'm sorry, but i don't quite understand how to use the first timer example provided, as well as how TSAs are BJ or non BJ. however, for the second one, i understand that i am supposed to continue the rest of the function after the wait with the callback function, call another function to finish up the job with the rest of the job. if i am not mistaken, this would mean breaking up the function, and although there is no problem with the current triggers, just to ask, is there any way to have the conditional wait inside the function and continue inside? or will this be impossible if i want it to be clean. thanks.
 

Dirac

22710180
Reaction score
147
Minigame_End_Check() is actually just a function that checks for a boolean that is going to be manually set to true when my "minigame" has ended
If you're setting it manually then why are you waiting for it in another trigger? Instead of stetting something to true, place all your actions there. Some thing you should know
- Using TSAs is just plain wrong at wc3 programming.(there's always a better way to do it)
- TSAs are highly inaccurate (0.01 timeouts are actually 0.5 or something like that)
- There are lots of way to prevent using timers, such as event detection, in your case i don't know why you even created one :p
 

Xbing

New Member
Reaction score
0
If you're setting it manually then why are you waiting for it in another trigger? Instead of stetting something to true, place all your actions there. Some thing you should know
- Using TSAs is just plain wrong at wc3 programming.(there's always a better way to do it)
- TSAs are highly inaccurate (0.01 timeouts are actually 0.5 or something like that)
- There are lots of way to prevent using timers, such as event detection, in your case i don't know why you even created one :p

because there are many triggers setting the boolean, as there are many minigames. i wouldn't want to paste what is after the wait all over so many triggers. also, if i were to make a global function such as Actions_After_Minigame_End(), and run it after the minigames, it would be again, messy as the things the function belongs to the originial trigger. then again, it sounds quite neat too.

but i would still like to explore using the conditional wait ;)
 

Dirac

22710180
Reaction score
147
That's why there are PUBLIC functions, that way you don't have to put all the actions in every trigger
JASS:
public function EndMinigame takes nothing returns nothing
actions go here
endfunction

Just call this function every time you end your minigame
JASS:
call EndMinigame()


I insist, do NOT use TSAs if you wan't your map to be efficient
 

Xbing

New Member
Reaction score
0
yup, i did it the functions way. just wanted to explore if there were any efficient ways of using that conditional wait loop. seems like it is always inefficient, even with timers right?
 

Xbing

New Member
Reaction score
0
noted. and thanks! +rep

*edit: and, i just got a problem. apparently, the callback assigned to the timer does not support loops. calling a function normally through triggered events made the loop function normally, but when called from the timer, it simply runs just one time. is it an error on my side, or is it that the callback cannot contain loops.

*edit solved the problem. loops did work. ironically, it was a TSA in the callback function causing the trouble. just finished making my whole map use timers instead of TSAs.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • 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
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +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