2019-03-20 snapshot (Updated)

Post anything about MX Simulator here. Please. I'm begging you.
aeffertz
Posts: 4031
Joined: Sat Sep 06, 2014 7:01 am
Team: Studio ATE
Location: Wiscansin

Re: 2019-03-20 snapshot (Updated)

Post by aeffertz »

jlv wrote:Changes:
  • Time reported to scripts is now adjusted for interpolation delay when spectating online.
Can this be adjusted at all? Still seems to be a second off.
Image
jlv
Site Admin
Posts: 14931
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: 2019-03-20 snapshot (Updated)

Post by jlv »

aeffertz wrote:
jlv wrote:Changes:
  • Time reported to scripts is now adjusted for interpolation delay when spectating online.
Can this be adjusted at all? Still seems to be a second off.
The gate drop or something else? It still does report the running order early. The times are correct but they'll arrive early.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
aeffertz
Posts: 4031
Joined: Sat Sep 06, 2014 7:01 am
Team: Studio ATE
Location: Wiscansin

Re: 2019-03-20 snapshot (Updated)

Post by aeffertz »

jlv wrote:
aeffertz wrote:
jlv wrote:Changes:
  • Time reported to scripts is now adjusted for interpolation delay when spectating online.
Can this be adjusted at all? Still seems to be a second off.
The gate drop or something else? It still does report the running order early. The times are correct but they'll arrive early.
Yeah, the gate drop sound is still ~ a second early.
Image
jlv
Site Admin
Posts: 14931
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: 2019-03-20 snapshot (Updated)

Post by jlv »

aeffertz wrote:Yeah, the gate drop sound is still ~ a second early.
Are you sure you're checking the time returned correctly? "mx.get_gate_drop_time" will return -1 until the time passes the gate drop time and return the gate drop time after that. With the time adjusted, it will stop returning -1 a second early relative to the adjusted time but the returned time should still be correct. So if you just check for -1 it won't work. You have to check that the value is positive, meaning it's valid, and that the current (adjusted) time is after the drop time. Something like this:

Code: Select all

/*
################################################################################
## Call g_gate_drop_handler on gate drop.
##
################################################################################
*/

var g_gate_drop_handler = function () { };

var g_gate_position_down = -1;
var g_gate_position_unknown = 0;
var g_gate_position_up = 1;

var g_gate_position = g_gate_position_unknown;

function gate_drop_frame_handler(seconds) {
        var gdt;

        gate_drop_frame_handler_prev(seconds);

        gdt = mx.get_gate_drop_time();

        if (gdt >= 0 && seconds > gdt) {
                if (g_gate_position == g_gate_position_up)
                        g_gate_drop_handler();
                g_gate_position = g_gate_position_down;
        } else
                g_gate_position = g_gate_position_up;
}

var gate_drop_frame_handler_prev = mx.frame_handler;
mx.frame_handler = gate_drop_frame_handler;

# Test handler
g_gate_drop_handler = function () { mx.message("Go!"); };
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
aeffertz
Posts: 4031
Joined: Sat Sep 06, 2014 7:01 am
Team: Studio ATE
Location: Wiscansin

Re: 2019-03-20 snapshot (Updated)

Post by aeffertz »

Ahh, okay. Yeah, right now it's just checking for once it's greater than 0. I'll change that.
Image
Post Reply