Author Topic: Creating a ships bell / timer function  (Read 6445 times)

newtron

  • Newbie
  • *
  • Posts: 15
Creating a ships bell / timer function
« on: April 09, 2017, 08:36:22 PM »
Hi all.  I am trying to find a way to create a timed event schedule based on a time loop or time only operator.  What I am trying to create is the 30 minute timer from Naval vessels, e.g. one bell every 30 minutes up to eight bells, then repeat.  Any sagely advice would be much appreciated.  Thanks for taking the time to read this and provide at advise.  Cheers - Newtron

newtron

  • Newbie
  • *
  • Posts: 15
Re: Creating a ships bell / timer function
« Reply #1 on: April 10, 2017, 11:58:23 AM »
So I have researched the text file and the forums here.  All the examples do not seem to work as written in VA 1.6.2, any thoughts/suggestions of what I can do to get them to work?

Rhaedas

  • Jr. Member
  • **
  • Posts: 72
Re: Creating a ships bell / timer function
« Reply #2 on: April 10, 2017, 01:33:22 PM »
Since VA commands can run at the same time, this isn't hard to do. I have one with mine that counts down every 60 seconds and then randomly determines if and what the ship might say out of the blue.

Just have a command to begin the timer, and have it count down in a loop. When it reaches zero, fire off the bell sound, and you can have another counter variable that determines how many times that bell sounds.

Do you need it syncronized with the real time? Instead of a counter variable you can have the loop compare the actual system time.

Perhaps a simpler way might be to show us what code you've tried to get working, and we can pick that apart. That way we can see clearer what you're trying to do also. You can right click on each command's code and select to copy as text, and then use the insert code here (the #) to preserve its format.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4780
  • RTFM
Re: Creating a ships bell / timer function
« Reply #3 on: April 10, 2017, 02:22:20 PM »
I have no idea how a ship's bell works, but I followed this wikipedia article assuming it's what you're looking for:
Code: [Select]
Start Loop While : [{EXP:1=1}] Equals '1'
    Begin Text Compare : [{EXP:{TIMEMINUTE} = 0 OR {TIMEMINUTE} = 30}] Equals '1'
        Set small int (condition) [HalfHours] value to the converted value of {EXP:({TIMEHOUR} * 2)}
        Begin Text Compare : [{EXP:{TIMEMINUTE} > 30}] Equals '1'
            Set small int (condition) [HalfHours] value as incremented by 1
        End Condition
        Set small int (condition) [Bells] value to 0
        Start Loop While : [HalfHours] Does Not Equal 0
            Set small int (condition) [HalfHours] value as decremented by 1
            Begin Small Integer Compare : [Bells] Is Less Than 8
                Set small int (condition) [Bells] value as incremented by 1
            Else
                Set small int (condition) [Bells] value to 1
            End Condition
        End Loop
        Set Boolean [TwoBells] to False
        Start Loop While : [Bells] Does Not Equal 0
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
            Pause 0,5 seconds
            Begin Boolean Compare : [TwoBells] Equals True
                Pause 0,5 seconds
                Set Boolean [TwoBells] to False
            Else
                Set Boolean [TwoBells] to True
            End Condition
            Set small int (condition) [Bells] value as decremented by 1
        End Loop
    End Condition
End Loop
Rings every half hour, pauses every two bells(E.G. three bells go "ding", "ding", pause, "ding").

newtron

  • Newbie
  • *
  • Posts: 15
Re: Creating a ships bell / timer function
« Reply #4 on: April 10, 2017, 03:11:40 PM »
Thank you both for your assistance I am transposing now.  Is there a verbal command needed to "start the clock"?  As for the bells you get one bell every half hour starting at midnight counting up to eight bells and repeat this for a 24h period.  I have all the audio files from 1 bell to 8bells already recorded and saved.  I would like to use those audio files if possible if not, I can trim the single bell down in time, to make it work.  Again thanks for the assistance, I will let you know how the testing goes in a bit.  Just got to wait for the time to be at :30 or :00.  Fingers crossed it works, I tried Pfeil's other coding for timed event/response and nothing fired.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4780
  • RTFM
Re: Creating a ships bell / timer function
« Reply #5 on: April 10, 2017, 03:48:41 PM »
Is there a verbal command needed to "start the clock"?
VoiceAttack commands don't start by themselves, so either a spoken phrase, keypress, button press, or mouse button press is required, depending on how you set up the command.

As for the bells you get one bell every half hour starting at midnight counting up to eight bells and repeat this for a 24h period.
That's what my example should do. Every half hour indefinitely, until stopped.

I have all the audio files from 1 bell to 8bells already recorded and saved.
For separate audio files, rather than one file that repeats:
Code: [Select]
Start Loop While : [{EXP:1=1}] Equals '1'
    Begin Text Compare : [{EXP:{TIMEMINUTE} = 0 OR {TIMEMINUTE} = 30}] Equals '1'
        Set small int (condition) [HalfHours] value to the converted value of {EXP:({TIMEHOUR} * 2)}
        Begin Text Compare : [{EXP:{TIMEMINUTE} > 30}] Equals '1'
            Set small int (condition) [HalfHours] value as incremented by 1
        End Condition
        Set small int (condition) [Bells] value to 0
        Start Loop While : [HalfHours] Does Not Equal 0
            Set small int (condition) [HalfHours] value as decremented by 1
            Begin Small Integer Compare : [Bells] Is Less Than 8
                Set small int (condition) [Bells] value as incremented by 1
            Else
                Set small int (condition) [Bells] value to 1
            End Condition
        End Loop
        Begin Small Integer Compare : [Bells] Equals 1
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 2
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 3
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 4
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 5
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 6
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 7
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        End Condition
        Pause 60 seconds
    End Condition
    Pause 1 second
End Loop
You'll have to modify the "Play a Sound" actions to point to your files, of course.

Note that there's a pause action at the end of the outermost condition. It simply makes the loop wait a minute before running again, to prevent the bell sound playing constantly during the minute of the half hour(something I intended to put in the first example).

Also note that there's a pause action before the end of the loop(I intended to put this in the other one as well), this prevents the loop from running as fast as it can when it really doesn't have to.


EDIT: If you'd rather not have the log entry when pausing for the minute:
Code: [Select]
Start Loop While : [{EXP:1=1}] Equals '1'
    Begin Text Compare : [{EXP:{TIMEMINUTE} = 0 OR {TIMEMINUTE} = 30}] Equals '1'
        Set small int (condition) [HalfHours] value to the converted value of {EXP:({TIMEHOUR} * 2)}
        Begin Text Compare : [{EXP:{TIMEMINUTE} > 30}] Equals '1'
            Set small int (condition) [HalfHours] value as incremented by 1
        End Condition
        Set small int (condition) [Bells] value to 0
        Start Loop While : [HalfHours] Does Not Equal 0
            Set small int (condition) [HalfHours] value as decremented by 1
            Begin Small Integer Compare : [Bells] Is Less Than 8
                Set small int (condition) [Bells] value as incremented by 1
            Else
                Set small int (condition) [Bells] value to 1
            End Condition
        End Loop
        Begin Small Integer Compare : [Bells] Equals 1
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 2
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 3
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 4
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 5
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 6
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Small Integer Compare : [Bells] Equals 7
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        End Condition
        Start Loop While : [{EXP:{TIMEMINUTE} = 0 OR {TIMEMINUTE} = 30}] Equals '1'
            Pause 3 seconds
        End Loop
    End Condition
    Pause 1 second
End Loop
(Three seconds is the maximum pause time that doesn't generate a log entry)
« Last Edit: April 10, 2017, 04:03:03 PM by Pfeil »

newtron

  • Newbie
  • *
  • Posts: 15
Re: Creating a ships bell / timer function
« Reply #6 on: April 10, 2017, 05:59:17 PM »
Hello.  Thanks for helping out.  I have run the command for a couple of hours now with no "dingy ding"  ;).  I am not sure why the bells do not sound off at the appropriate times. I have checked the code a couple of times, aside from the error noted at the bottom, wish lack of attention to detail on my part created, then corrected in the line reviews.  I have set this command to execute upon launch of the profile.  Doing so, I am able to get the audible time check when the command fires off, but I get nothing after that at the 30m or hour marks.


Code: [Select]
Execute command, 'time check from the pilot house; what time is it [please;]' (and wait until it completes)
Start Loop While : [{EXP:1=1}] Equals '1'
    Begin Text Compare : [{EXP:{TIMEMINUTE} = 0 OR [TIMEMINUTE} = 30}] Equals '1'
        Set small int (condition) [HalfHours] value to the converted value of {EXP:({TIMEHOUR} * 2)}
        Begin Text Compare : [{EXP:{TIMEMINUTES} > 30}] Equals '1'
            Set small int (condition) [HalfHours] value as incremented by 1
        End Condition
        Set small int (condition) [Bells] value to 0
        Start Loop While : [Halfhours] Does Not Equal 0
            Set small int (condition) [HalfHours] value as decremented by 1
            Begin Small Integer Compare : [Bells] Is Less Than 8
                Set small int (condition) [Bells] value as incremented by 1
            Else
                Set small int (condition) [Bells] value to 1
            End Condition
        End Loop
        Begin Small Integer Compare : [Bells] Equals 1
            Play sound, 'C:\Windows\Media\1 bell_2.wav'
        Else If Small Integer Compare : [bells] Equals 2
            Play sound, 'C:\Windows\Media\2 bells.wav'
        Else If Small Integer Compare : [Bells] Equals 3
            Play sound, 'C:\Windows\Media\3 bells.wav'
        Else If Small Integer Compare : [Bells] Equals 4
            Play sound, 'C:\Windows\Media\4 bells.wav'
        Else If Small Integer Compare : [Bells] Equals 5
            Play sound, 'C:\Windows\Media\5 bells.wav'
        Else If Small Integer Compare : [Bells] Equals 6
            Play sound, 'C:\Windows\Media\6 bells.wav'
        Else If Small Integer Compare : [Bells] Equals 7
            Play sound, 'C:\Windows\Media\7 bells.wav'
        Else
            Play sound, 'C:\Windows\Media\8 bells.wav'
        End Condition
        Pause 60 seconds
    End Condition
    Pause 1 second
End Loop


I created an error with the ending value on line 9, placed quotes around the zero. It would be handy if the "start loop while" condition type (small int/text/int/boolean/date&time) were clear on each line of code you use as examples.  I could not find any other reason/error preventing this from functioning properly.  Thanks for your time and assistance on this matter.



Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4780
  • RTFM
Re: Creating a ships bell / timer function
« Reply #7 on: April 10, 2017, 06:17:42 PM »
I am not sure why the bells do not sound off at the appropriate times.
Aside from a typo where you have "{TIMEMINUTES}" rather than "{TIMEMINUTE}", what I can check looks right.

It would be handy if the "start loop while" condition type (small int/text/int/boolean/date&time) were clear on each line of code you use as examples.
I paste direct output from VoiceAttack's "Copy as Text" feature, which doesn't include markers for that. However, the datatypes can be glanced from any action that sets them.


I've attached the commands so you can import them directly into your profile instead.

newtron

  • Newbie
  • *
  • Posts: 15
Re: Creating a ships bell / timer function
« Reply #8 on: April 11, 2017, 01:50:46 PM »
Pheil,

Thanks again for the help.  I copied and used your vap file.  It works now, sort of, all the even number bells work with no issues, it is the odd numbers not fire at all.  Saying that, when an odd should fire, what actually happens is the corresponding even ones fires off????  Not sure why this is happening.  I have attached a short video link:  https://youtu.be/D7a0Zb2VEqw

the 1:30pm bells should be 3 bells not 2.  At 2pm it worked fine.  At 2:30pm it should have been 5 bells not four.  this is the same for all half hours or odd bells  The 12:30pm sound should be 1 bell, 1:30pm 3 bells, 2:30pm 5 bells, 3:30pm 7 bells.  The 12:00 should be 8 bells, 1pm - 2 bells, 2pm - 4bells, 3pm - 6 bells, 4pm should be 8 bells, then repeat from 1 again.

I can make due with this as is, but if there is a way to get the odd numbers firing off at the half hour, let's try.  Again thank you for your patience and assistance with this.

V/r,

Newtron
« Last Edit: April 11, 2017, 01:57:35 PM by newtron »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4780
  • RTFM
Re: Creating a ships bell / timer function
« Reply #9 on: April 11, 2017, 03:13:36 PM »
Simple mistake on my part:
Code: [Select]
Begin Text Compare : [{EXP:{TIMEMINUTES} > 30}] Equals '1'Should be
Code: [Select]
Begin Text Compare : [{EXP:{TIMEMINUTES} = 30}] Equals '1'
Though, I was pondering this yesterday evening, and while the given examples work fine(providing the typos are fixed), I've realized they're overly complicated for a system using only static values.

If the amount of hours in a day ever changes, use the earlier examples, otherwise, you could just do it this way:
Code: [Select]
Start Loop While : [{EXP:1=1}] Equals '1'
    Begin Text Compare : [{EXP:{TIMEMINUTE} = 0 OR {TIMEMINUTE} = 30}] Equals '1'
        Begin Text Compare : [{EXP:'{time}' = '12:30' OR  '{time}' = '4:30' Or '{time}' = '8:30'}] Equals '1'
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Text Compare : [{EXP:'{time}' = '1:00' OR  '{time}' = '5:00' Or '{time}' = '9:00'}] Equals '1'
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Text Compare : [{EXP:'{time}' = '1:30' OR  '{time}' = '5:30' Or '{time}' = '9:30'}] Equals '1'
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Text Compare : [{EXP:'{time}' = '2:00' OR  '{time}' = '6:00' Or '{time}' = '10:00'}] Equals '1'
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Text Compare : [{EXP:'{time}' = '2:30' OR  '{time}' = '6:30' Or '{time}' = '10:30'}] Equals '1'
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Text Compare : [{EXP:'{time}' = '3:00' OR  '{time}' = '7:00' Or '{time}' = '11:00'}] Equals '1'
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Text Compare : [{EXP:'{time}' = '3:30' OR  '{time}' = '7:30' Or '{time}' = '11:30'}] Equals '1'
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        Else If Text Compare : [{EXP:'{time}' = '4:00' OR  '{time}' = '8:00' Or '{time}' = '12:00'}] Equals '1'
            Play sound, 'C:\Windows\Media\Windows Ding.wav'
        End Condition
        Pause 60 seconds
    End Condition
    Pause 1 second
End Loop
New example also attached for import.
« Last Edit: April 11, 2017, 03:31:10 PM by Pfeil »

newtron

  • Newbie
  • *
  • Posts: 15
Re: Creating a ships bell / timer function
« Reply #10 on: April 11, 2017, 08:33:23 PM »
Phiel,

Thanks.  I opted for the single line modification.  The bells are ringing, lol. 

V/r,

Newtron