Previous Thread
Next Thread
Print Thread
Rate This Thread
Hop To
Page 2 of 2 1 2
#4512540 - 03/24/20 09:46 AM Re: Start a timer on a key press... [Re: Drakoz]  
Joined: Mar 2020
Posts: 12
dmonds Offline
Junior Member
dmonds  Offline
Junior Member

Joined: Mar 2020
Posts: 12
Auckland, New Zealand
Hi @Drakoz,

Really great to see this sort of examples now available.
I've been searching occasionally for last 2-3 years and only recently come across some fantastic advanced scripting from DCS World and here.

Keep it up....I'm loving it!

Which device was this written for?

And, which version of Windows was it written on?

Reason I ask is that when I load it up and run it, my throttle seems to be inverted (ie 100% at home position decreasing to 0 when fully forward) and secondly, when the console indicates it is speaking...I get no sound.

I have a Thrustmaster WARTHOG and am on Win10.
I have never (to date) been able to get 'spawn' to work on Win10 although I know for a fact it works on Win7.

Cheers
dmonds

Edit: just discovered Windows Defender has classified the speak function action as a virus and shut it down.
Trying to run from a command line gives me "No Access" message even though I'm running a command prompt as admin.

Last edited by dmonds; 03/24/20 10:23 AM.
Inline advert (2nd and 3rd post)

#4513166 - 03/28/20 01:32 PM Re: Start a timer on a key press... [Re: Joao Muas]  
Joined: Jul 2016
Posts: 61
Drakoz Offline
Junior Member
Drakoz  Offline
Junior Member

Joined: Jul 2016
Posts: 61
My examples were written for the Warthog Throttle, under Windows 10.

Regarding the axis being reversed, that is the default for a Warthog Left/Right axis (axis pushed all the way forward is 0% or rather the axis is at -32767 out of a range of -32767 to +32768). It is determined by the following command:

MapAxis(&Throttle, THR_LEFT, DX_ZROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);

AXIS_NORMAL sets it that way. Maybe your scripts have AXIS_REVERSED on your MapAxis commands and you forgot you did it that way?

As for getting no sound from the Speak() function, if you have never been able to get spawn to work, that is probably why my Speak() function isn't working either, since I am using the spawn command. Have you installed the TARGET software to a different location than the default? That might have some impact on spawn working. It shouldn't, but be aware that spawn.exe is in the Thrustmater TARGET folder, and maybe there is some reason it doesn't work when installed to a non-default location. Maybe???

As for Windows Defender preventing my Speak() function working, that is also very likely depending on your Windows Defender settings. Or it could be related to your Internet Options settings. It is because the speak function is being run through a Windows HTML Application (as executed by mshta.exe, a Windows program). Since this program is a VBScript interpreter for use on HTML like functions, security is affected by how you have your Internet Options set, or possibly by how the virus software is setup regarding Internet related stuff. Sadly, the number of possible ways you can set virus software or Internet Options such that it prevents mshta.exe from working is extensive. Or maybe, if you have removed or never installed Internet Explorer, mshta.exe may not work either. These are all theoretical reasons why it may not work based on my reading up on HTML Applications, but not something I have tested extensively.

All I can say is what I have setup. My Internet Options are completely default (as installed by Windows from a fresh install). I use Norton Virus software, but I have tested this on another Windows 10 machine with Windows Defender and it also worked. But that Windows 10 machine was updated from Windows 7 many years ago. So again, too many variables unfortunately.

I have discussed similar issues with other people trying to use mshta.exe to do what I am doing. Sadly, it may just be that this is not a viable solution for everyone. Something I am very bummed about.

#4521724 - 05/21/20 07:49 AM Re: Start a timer on a key press... [Re: Joao Muas]  
Joined: Mar 2020
Posts: 12
dmonds Offline
Junior Member
dmonds  Offline
Junior Member

Joined: Mar 2020
Posts: 12
Auckland, New Zealand
@Drakoz,

The above timer examples are using throttle position to trigger and are awesome.

I'm having trouble wrapping my head around how I can use the example to trigger a timer based on a variable value.

Example:

Timeout = 120 seconds;

If 'myvariable' == 0 start a countdown.
Every 10 seconds, announce time left (via printf is fine) and check if 'myvariable' is still == 0.
If so, continue
If not, abort countdown.

Thanks
dmonds

#4521965 - 05/22/20 05:13 PM Re: Start a timer on a key press... [Re: dmonds]  
Joined: Jul 2016
Posts: 61
Drakoz Offline
Junior Member
Drakoz  Offline
Junior Member

Joined: Jul 2016
Posts: 61
Originally Posted by dmonds
The above timer examples are using throttle position to trigger and are awesome.

I'm having trouble wrapping my head around how I can use the example to trigger a timer based on a variable value.


Simple answer, you need to use an REXEC to call a function that checks your variable, but would otherwise start and stop the timer the same as my last example.


So in my example, I put WEPTimerStartStop(&o, x); in EventHandle(), but this will only execute if a button or axis event occurs. If you don't touch your controller, nothing will ever call EventHandle(). So it doesn't help you for monitoring a variable. So instead, you need to use REXEC to call WEPTimerStartStop() at some interval.

Then, inside WEPTimerStartStop(), change the if statements to check the variable instead of the axis values.

So replace these lines:
if ((&o == &Throttle) & (x == THR_LEFT)) ...
...
if (percent >= 90) ...

with something like:
if (myvariable == 0) ...

We don't need to check the axis value, so delete that if statement and code below it. Then my "if (percent >=90)" is where you want to check your variable, myvariable.

Or something along those lines. Let me know if that gets you started.

Page 2 of 2 1 2

Moderated by  RacerGT 

Quick Search
Recent Articles
Support SimHQ

If you shop on Amazon use this Amazon link to support SimHQ
.
Social


Recent Topics
Actors portraying US Presidents
by PanzerMeyer. 04/19/24 12:19 PM
Dickey Betts was 80
by Rick_Rawlings. 04/19/24 01:11 AM
Exodus
by RedOneAlpha. 04/18/24 05:46 PM
Grumman Wildcat unique landing gear
by Coot. 04/17/24 03:54 PM
Peter Higgs was 94
by Rick_Rawlings. 04/17/24 12:28 AM
Whitey Herzog was 92
by F4UDash4. 04/16/24 04:41 PM
Anyone can tell me what this is?
by NoFlyBoy. 04/16/24 04:10 PM
10 Years ago MV Sewol
by wormfood. 04/15/24 08:25 PM
Pride Of Jenni race win
by NoFlyBoy. 04/15/24 12:22 AM
Copyright 1997-2016, SimHQ Inc. All Rights Reserved.

Powered by UBB.threads™ PHP Forum Software 7.6.0