Author Topic: Conditional implementation based on variable cooldowns  (Read 5518 times)

Songbird

  • Guest
Conditional implementation based on variable cooldowns
« on: May 24, 2017, 03:55:24 PM »
Hi everyone,

I'm trying to stop execution of a skill if the skill cooldown time has not passed since the last execution.
This is my current code trying to accomplish this:

Begin Boolean Compare : [Cloak_State] Equals False
    Set date [CD_Fin] value to the value of [[ExeTime_Cloak] + [CD_Cloak]]
    Begin Date Compare : [CD_Fin] Is Less Than Current Date/Time
        Say, 'Cloaking'
        Press Tab key and hold for 0.1 seconds and release
        Set Boolean [Cloak_State] to True
    Else
        Say, 'Cloak still on cooldown'
    End Condition
Else
    Say, 'Decloaking'
    Press Tab key and hold for 0.1 seconds and release
    Set date [ExeTime_Cloak] value to the current date/time
    Set Boolean [Cloak_State] to False
End Condition

[ExeTime_Cloak], [CD_Cloak] as well as [CD_Fin] should all be date variables.  Also I need help in setting [CD_Cloak] to just 15 seconds.

Any advice would be greatly appreciated.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Conditional implementation based on variable cooldowns
« Reply #1 on: May 24, 2017, 04:21:00 PM »
The current implementation of the "Date/Time" value doesn't facilitate the use of a variable to add or subtract time. In addition, it represents a specific point in time, not a timespan.

Without the requirement for a variable setting, you could use the "Add" option of the "Set a Date/Time Value" action to add 15 seconds to the start time, and check whether it's Less than the current date/time, as you're doing in your example.

Otherwise, you'll have to use the "{DATETICKS}" token and decimal values:
Code: [Select]
Begin Boolean Compare : [Cloak_State] Equals False
    Set decimal [CD_Fin] value to the value of [ExeTime_Cloak]
    Set decimal [CD_Fin] to [CD_Fin] plus [CD_Cloak]
    Begin Decimal Compare : [{DATETICKS}] Is Greater Than [CD_Fin]
        Say, 'Cloaking'
        Press Tab key and hold for 0.1 seconds and release
        Set Boolean [Cloak_State] to True
    Else
        Say, 'Cloak still on cooldown'
    End Condition
Else
    Say, 'Decloaking'
    Press Tab key and hold for 0.1 seconds and release
    Set decimal [ExeTime_Cloak] value to the converted value of {DATETICKS}
    Set Boolean [Cloak_State] to False
End Condition
Where "CD_Cloak" has a value of 150000000 (One second is 10,000,000 ticks).

You could also use "{EXP:}" to set the value of CD_Fin to do it in one action instead of two:
Code: [Select]
Set decimal [CD_Fin] value to the value of [{EXP: {DEC:ExeTime_Cloak} + {DEC:CD_Cloak}}]
However, this may not work with all system locales.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Conditional implementation based on variable cooldowns
« Reply #2 on: May 24, 2017, 06:44:13 PM »
Quote
The current implementation of the "Date/Time" value doesn't facilitate the use of a variable to add or subtract time.
Ooooooooooooh.  Ok.  I think that needs to be in there.

Songbird

  • Guest
Re: Conditional implementation based on variable cooldowns
« Reply #3 on: May 25, 2017, 02:47:05 AM »
Thank you very much Pfeil, I can't wait to try this out.  Will let you know how it works out.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Conditional implementation based on variable cooldowns
« Reply #4 on: May 25, 2017, 10:38:36 PM »
Quote
The current implementation of the "Date/Time" value doesn't facilitate the use of a variable to add or subtract time.

The latest beta has a variable (text) input where the numeric input used to be.  Thanks for the heads-up on that one.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Conditional implementation based on variable cooldowns
« Reply #5 on: May 26, 2017, 07:03:14 AM »
The latest beta has a variable (text) input where the numeric input used to be.
I can't seem to get tokens to work; When something like "{INT:inttest}" or "{EXP:1}"(to emulate direct numeric entry) is used, the result is always "Not Set", even if the date value had already been set.

In addition, if the integer values' name is a number, the above behavior applies as well.


I do have "Evaluate Not Set as current date/time" checked, though I tested with that unchecked(and the date value set beforehand) and found the result to be the same.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Conditional implementation based on variable cooldowns
« Reply #6 on: May 26, 2017, 03:46:49 PM »
Awwww....  @#$@$#@

Yeah... I decided to add a little more code to that at the end (again) and I broke it.   Was hoping to get this out quick before the next release.  I don't think I want to do an entire beta release for this one, though.

Edit:  I put a fixed version out in the, 'unofficial' bin if you want it:  http://www.voiceattack.com/unofficial

« Last Edit: May 26, 2017, 04:03:41 PM by Gary »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Conditional implementation based on variable cooldowns
« Reply #7 on: May 26, 2017, 09:28:04 PM »
All appears to be working now.

Though, I feel that the tooltip isn't quite clear, in that an integer(whole) number is used directly, whereas anything else(including non-integer token output) is used as a variable name.

E.G.
Code: [Select]
Set date [test] value to 1/01/2001 0:00:00
Set integer [1] value to 5
Set date [test] to [test] plus [1] hours
Write '[Blue] {TIME:test}' to log
or
Code: [Select]
Set date [test] value to 1/01/2001 0:00:00
Set integer [1] value to 5
Set date [test] to [test] plus [{EXP:1}] hours
Write '[Blue] {TIME:test}' to log
Will write "1:00" to the log

Whereas
Code: [Select]
Set date [test] value to 1/01/2001 0:00:00
Set integer [1.1] value to 5
Set date [test] to [test] plus [1.1] hours
Write '[Blue] {TIME:test}' to log
or
Code: [Select]
Set date [test] value to 1/01/2001 0:00:00
Set integer [1.1] value to 5
Set date [test] to [test] plus [{EXP:1.1}] hours
Write '[Blue] {TIME:test}' to log
Will write "5:00" to the log

Currently I would infer from the tooltip, which states "Indicate a large integer variable or token here to use in your calculation", that the input field either takes a variable name or a token, not a direct value.

The VoiceAttackHelp.pdf section on "Set a Date/Time Value", which states "Note that this input box can contain a large integer variable, as well as any combination of tokens that may resolve into an integer.", doesn't explicitly point out that any integer number will not be resolved to a variable name either, but I'm not sure whether anyone names their variables in this manner.


As an aside, the VoiceAttackHelp.pdf section on "Set a Date/Time Value", still has the screenshot showing numeric-only input.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Conditional implementation based on variable cooldowns
« Reply #8 on: May 26, 2017, 09:38:23 PM »
Thanks, bud.  I'll touch it up.

Songbird

  • Guest
Re: Conditional implementation based on variable cooldowns
« Reply #9 on: May 29, 2017, 02:28:40 PM »
Finally got around to some coding, had some issues with the decimal compare the way you wrote it Pfeil, it did not see {DATETICS} as decimal and When I tried {EXP:{DEC:{DATETICKS}}} the dialog complained that : were not allowed in Variable names.  I got around the problem with another Set decimal statement.  It is now working exactly like I need it to.  Thanks you very much for all your input.  I was very excited to see that this conversation made it into the new release.  I love this application thanks very much for your efforts on it Gary.

This is the code that worked for me in the end:

Begin Boolean Compare : [Cloak_State] Equals False
    Set decimal [Now_Time] value to the converted value of {DATETICKS}
    Begin Decimal Compare : [CD_Cloak_Fin] Is Less Than [Now_Time]
        Say, 'Cloaking'
        Press Tab key and hold for 0.1 seconds and release
        Set Boolean [Cloak_State] to True
    Else
        Say, 'Cloak still on cooldown'
    End Condition
Else
    Say, 'Decloaking'
    Press Tab key and hold for 0.1 seconds and release
    Set decimal [CD_Cloak_Fin] value to the converted value of {DATETICKS}
    Set decimal [CD_Cloak_Fin] to [CD_Cloak_Fin] plus [CD_Cloak]
    Set Boolean [Cloak_State] to False
End Condition

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Conditional implementation based on variable cooldowns
« Reply #10 on: May 29, 2017, 08:35:30 PM »
had some issues with the decimal compare the way you wrote it Pfeil, it did not see {DATETICS} as decimal and When I tried {EXP:{DEC:{DATETICKS}}} the dialog complained that : were not allowed in Variable names.
My mistake, only the "Text" compare accepts tokens.

It should've been
Code: [Select]
Begin Boolean Compare : [Cloak_State] Equals False
    Set decimal [CD_Fin] value to the value of [ExeTime_Cloak]
    Set decimal [CD_Fin] to [CD_Fin] plus [CD_Cloak]
    Begin Text Compare : [{EXP: {DATETICKS} > {DEC:CD_Fin}}] Equals '1'
        Say, 'Cloaking'
        Press Tab key and hold for 0.1 seconds and release
        Set Boolean [Cloak_State] to True
    Else
        Say, 'Cloak still on cooldown'
    End Condition
Else
    Say, 'Decloaking'
    Press Tab key and hold for 0.1 seconds and release
    Set decimal [ExeTime_Cloak] value to the converted value of {DATETICKS}
    Set Boolean [Cloak_State] to False
End Condition