• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

P3D v4 Apparent repeat when single event wanted

Roy Holmes

Resource contributor
Messages
1,803
Country
us-virginia
I appear to be having more than one event occur after I use the following code. I'm using FSX schema and multiple macros.

Code:
<Trigger id="LANDING_LIGHT_HOME">
        <KeyEvent>LANDING_LIGHT_HOME</KeyEvent>
        <Script>
                   Do something once
    </Script>
I have the relevant button on my stick set to no repeat but I usually get two events happening.
Could be my stick is getting old and trembling a bit (like me) but I'd like to come up with a way to cancel the "Do something once" code after it happens once.
I suppose what might be happening is that because the above code is not in line with the program cycling it may be affecting two cycles.
The do something is a series of actions.
Anyone got an idea on how to fix this?
Roy
 
Messages
1,564
Country
thailand
I'll take a swing at it.

Events and traps are queued and processed sequentially at the end of each cycle. What if you use the value in a storage register to conditionally process the 'do something once' code. The idea is similar to an init sequence often used in gauges. My presumption is that the double/multiple event is thrown in the same cycle as the initial one:

Code:
<Trigger id="LANDING_LIGHT_HOME">
  <KeyEvent>LANDING_LIGHT_HOME</KeyEvent>
    <Script>
       l20 0 ==
         if{
           Do something once
           1 s20
         }
    </Script>


At the start of the next cycle, register 20 will be back to 0. I don't know when registers are cleared ... before queued events are processed? after? That would make a difference.

I haven't tested this and I have some doubts that it will work, but it would at least be simple to try. I'll also note that I'm unfamiliar with <Trigger>, so apologies if I've missed something related to that.

The other idea is to remap the event trap to use another button on the joystick to see if you get better action.

Bob
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
At the start of the next cycle, register 20 will be back to 0. I don't know when registers are cleared ... before queued events are processed? after? That would make a difference.

Hi Bob,
Register values in <Event> scripts are cleared after the script is executed. It means your solution won't (or shouldn't) work, considering Roy declares the event is executed twice.
A solution I use in different situations is this:

Code:
    <Script>
       (L:MyVar,bool) 
        if{
             0 (>L:MyVar,bool) 
           }
        els{
                Do something once
                 1 (>L:MyVar,bool) 
             }
   </Script>

This will work for a unintended duplicated event. Bear in mind it won't if the event is executed only once.

Tom
 
Messages
440
Country
us-wisconsin
Roy,
Most likely you have already checked, just adding 2 cents.. Have you checked to see if the button itself is sending 2 commands? Possibly on the down press and then on the release?
A quick check with FSUIPC logging "non-axis events" will confirm.

Roman
 

Roy Holmes

Resource contributor
Messages
1,803
Country
us-virginia
Roman,
That was a good idea. I have not checked with FSUIPC but if I press down and delay the release two events happen from the down press and none from the release. I'm firing guided weapons. One guides and the other goes ballistic and dances around. I'll try the suggested code changes.
Roy
 
Messages
1,564
Country
thailand
Roy,

The code change could run into trouble if your trembling old joystick ever fires three or more events, or somehow happens to fire the duplicate events but in sequential gauge update cycles (is that what you're getting at in your initial post?).

If so, you could try something like this:

Code:
<Update>
    (L:MyVar, bool) 1 ==
        if{
            (L:CycleCount, enum) ++ (>L:CycleCount, enum)
            (L:CycleCount, enum) 2 ==
                if{ 0 d (>L:MyVar, bool) (>L:CycleCount, enum) }
        }           
</Update>                   

<Script>                   
    (L:MyVar, bool) !
        if{
            Do something once
            1 (>L:MyVar, bool)
        }
</Script>


Or this

Bob
 

Roy Holmes

Resource contributor
Messages
1,803
Country
us-virginia
I put a "drop counter" in the event script which showed that I was getting two drops for every press. I used the "myvar" code from Tom and it allowed only one drop. I then reset the lvar in an update which happened sufficiently long after the first drop so that I could make more than 1.
So what I ended up with was:
Code:
 <Script> (L:MyVar,bool)  0 ==
        if{ (L:dropcount, number) 1 + (&gt; L:dropcount, number) 1 (>L:MyVar,bool) @weapon_drop }
       </Script>
And a call to
Code:
<Macro Name="myvar">
        <MacroValue>
        0 (>L:MyVar,bool)
                      </MacroValue>
    </Macro>

In a update.
That allowed me to make 6 single drops one after the other with each weapon guiding to target

I came back to post this and found my friend Bob had done much the same thing!
I used the 0 state of myvar so that it accepted the first input and barred the second. That took care of the situation where someone else might not have the issue.
Roy
 
Top