部分样例

通常情况下,回中力应该是都有的,一般可以单独列为一个效果。

set_spring_force(0, 0x7fff);//可以单独列为一个效果
set_spring_force(1, 0x7fff);//可以单独列为一个效果

襟翼震动 #

set_spring_force(0, 0x7fff);
set_spring_force(1, 0x7fff);
if (flap <0.5 && flap>0.1) { 
    set_periodic(20, 0x7fff, 0);
}
else
{
    set_periodic(0, 0, 0 );
}

MSFS配平随动 #

遥测值为YOKE X POSITION WITH AP,YOKE Y POSITION WITH AP,定义为xxyy

set_spring_force(0, 0x7fff);//可以单独列为一个效果
set_spring_force(1, 0x7fff);//可以单独列为一个效果
set_spring_offset(0,(16383*xx*5).to_int());
set_spring_offset(1,(16383*yy*5).to_int());

MSFS常用效果 #

下面这个json的内容保存到一个json文件,然后软件加载即可。

{
    "data": [
        {
            "id": 1,
            "datum_name": "YOKE X POSITION WITH AP",
            "units_name": "Position\n(-16K to 0)",
            "epsilon": 0.0001,
            "var_name": "xx"
        },
        {
            "id": 2,
            "datum_name": "YOKE Y POSITION WITH AP",
            "units_name": "Position\n(-16K to 0)",
            "epsilon": 0.0001,
            "var_name": "yy"
        },
        {
            "id": 3,
            "datum_name": "FLAPS HANDLE PERCENT",
            "units_name": "Percent Over 100",
            "epsilon": 0.001,
            "var_name": "flap"
        },
        {
            "id": 4,
            "datum_name": "STALL WARNING",
            "units_name": "Bool",
            "epsilon": 0.001,
            "var_name": "stall"
        }
    ],
    "effect": [
        {
            "id": 2,
            "effect_name": "LI",
            "code": "set_spring_force(0, 0x7fff);//可以单独列为一个效果\r\nset_spring_force(1, 0x7fff);//可以单独列为一个效果"
        },
        {
            "id": 4,
            "effect_name": "AP",
            "code": "set_spring_offset(0,(16383*xx*2).to_int());\r\nset_spring_offset(1,(16383*yy*2).to_int());"
        },
        {
            "id": 1,
            "effect_name": "FLAP",
            "code": "if (flap <0.5 && flap>0.1) { \r\n    set_periodic(10, 0x4fff.to_int(), 0.0);\r\n}"
        },
        {
            "id": 2,
            "effect_name": "stall",
            "code": "if stall == 1 { \r\n    set_periodic(5, 0x1fff.to_int(), 0.0);\r\n}"
        }
    ],
    "telemtpye": "Msfs2020"
}

xplane 杆力随空速改变 #

let f = TAS/30*0x7fff;
if (f>0x7fff){
       f=0x7fff;
}
f=f.to_int();
set_spring_force(0,f);
set_spring_force(1,f);

xplane 各种效果 #

下面这个json的内容保存到一个json文件,然后软件加载即可。

{
    "data": [
        {
            "id": 1,
            "datum_name": "APPitch",
            "units_name": "",
            "epsilon": 0.0,
            "var_name": "bb"
        },
        {
            "id": 2,
            "datum_name": "APRoll",
            "units_name": "",
            "epsilon": 0.0,
            "var_name": "aa"
        },
        {
            "id": 3,
            "datum_name": "FDPitch",
            "units_name": "",
            "epsilon": 0.0,
            "var_name": "pitch"
        },
        {
            "id": 4,
            "datum_name": "FDRoll",
            "units_name": "",
            "epsilon": 0.0,
            "var_name": "roll"
        },
        {
            "id": 5,
            "datum_name": "Flaps",
            "units_name": "",
            "epsilon": 0.000001,
            "var_name": "flp"
        },
        {
            "id": 6,
            "datum_name": "StallTest1",
            "units_name": "",
            "epsilon": 0.1,
            "var_name": "st1"
        },
        {
            "id": 7,
            "datum_name": "StallTest2",
            "units_name": "",
            "epsilon": 0.1,
            "var_name": "st2"
        }
    ],
    "effect": [
        {
            "id": 1,
            "effect_name": "",
            "code": "set_spring_force(0,0x3fff);\nset_spring_force(1,0x4fff);\n\nif(aa>0) { set_spring_offset(0,(16383*roll*1).to_int());}\nif(bb>0) { set_spring_offset(1,(16383*pitch*1).to_int());}\n"
        },
        {
            "id": 2,
            "effect_name": "",
            "code": "if (st1>0) {\nset_periodic(50,50000.to_int(),0.0 );\n}\nif (st2>0) {\nset_periodic(50,50000.to_int(),0.0 );\n}\nlet normal_positions = [1.0, 0.875, 0.75, 0.625, 0.5, 0.375, 0.25, 0.125, 0.0];\nlet is_normal = false;\nfor pos in normal_positions {\n    if (flp - pos).abs() < 0.03 {\n        is_normal = true;\n        break;\n    }\n}\nif !is_normal {\n    set_periodic(1000, 1000.to_int(), 1.0);\n} else {\n    set_periodic(0, 0, 0);\n}"
        }
    ],
    "telemtpye": "Xplane"
}

dsc机炮开火震动 #

这个存为config.json加载到软件中

{"data":[
    {"id":3,"datum_name":"Gun","units_name":"","epsilon":0.0,"var_name":"ammo"}
    ],
    "effect":[
            {"id":0,"effect_name":"gunfire","code":"if (last_ammo > ammo){\n    set_periodic(50.to_int(),0x8fff.to_int(),0.0);\n    stop();\n}\n\n"}
        ],
        "telemtpye":"DCS"
}