Rosso Laboratory

Rosso Laboratory

主に鉄道模型シミュレーター(VRM)などの仮想鉄道アプリを扱うブログです。またHDR写真の記事も書いています。

ノッチ操作スクリプト


昨日の続きです。

    di = obj.GetDict()
    if ev == 'init':
        obj.SetInputMode(1)
        obj.SetEventKeyDown('A')
        obj.SetEventKeyDown('Z')
        di['notch'] = 0
(中略)
    elif ev == 'keydown':
        if param['keycode'] == 'A':
            di['notch'] = di['notch'] - 1
            if di['notch'] == -10:
                di['notch'] = -9
            notchChange(obj,di['notch'])
        if param['keycode'] == 'Z':
            di['notch'] = di['notch'] + 1
            if di['notch'] == 6:
                di['notch'] = 5
            notchChange(obj,di['notch'])

def notchChange(obj,notch):
    if notch == -9:
        obj.SetNotchFactor(-3, 1.5)
        obj.SetCurrentNotch(-3)
        vrmapi.LOG('EB')
    elif notch == -8:
        obj.SetNotchFactor(-2, 1.5)
        obj.SetCurrentNotch(-2)
        vrmapi.LOG('B8')
    elif notch == -7:
        obj.SetNotchFactor(-2, 1.25)
        obj.SetCurrentNotch(-2)
        vrmapi.LOG('B7')
    elif notch == -6:
        obj.SetNotchFactor(-2, 1.0)
        obj.SetCurrentNotch(-2)
        vrmapi.LOG('B6')
    elif notch == -5:
        obj.SetNotchFactor(-2, 0.75)
        obj.SetCurrentNotch(-2)
        vrmapi.LOG('B5')
    elif notch == -4:
        obj.SetNotchFactor(-2, 0.5)
        obj.SetCurrentNotch(-2)
        vrmapi.LOG('B4')
    elif notch == -3:
        obj.SetNotchFactor(-2, 0.25)
        obj.SetCurrentNotch(-2)
        vrmapi.LOG('B3')
    elif notch == -2:
        obj.SetNotchFactor(-2, 0.1)
        obj.SetCurrentNotch(-2)
        vrmapi.LOG('B2')
    elif notch == -1:
        obj.SetNotchFactor(-2, 0.05)
        obj.SetCurrentNotch(-2)
        vrmapi.LOG('B1')
    elif notch == 0:
        obj.SetNotchFactor(0, 0.1)
        obj.SetCurrentNotch(0)
        vrmapi.LOG('N')
    elif notch == 1:
        obj.SetNotchFactor(5, 0.5)
        obj.SetCurrentNotch(5)
        vrmapi.LOG('P1')
    elif notch == 2:
        obj.SetNotchFactor(5, 1.0)
        obj.SetCurrentNotch(5)
        vrmapi.LOG('P2')
    elif notch == 3:
        obj.SetNotchFactor(5, 2.0)
        obj.SetCurrentNotch(5)
        vrmapi.LOG('P3')
    elif notch == 4:
        obj.SetNotchFactor(5, 2.5)
        obj.SetCurrentNotch(5)
        vrmapi.LOG('P4')
    elif notch == 5:
        obj.SetNotchFactor(5, 3.0)
        obj.SetCurrentNotch(5)
        vrmapi.LOG('P5')

ということで出来上がったのですが、15段というか制動8段はキー操作が間に合いません(^_^;) ホーム突入でN~B7~B5ぐらいで止まっちゃいます。2つのキーでやるなら[EB]/[B3]~[B1]/[N]/[P1]~[P3]の8段ぐらいでないと無理ですね。


<追記>
昨夜shirokumaさんとビューわかしおさんから「obj.SetNotchBRK(8)」と「obj.SetNotchACC(5)」を使って↑↓キー自体の設定を変えてしまうという方法をお聞きしました。こちらの方が簡単でしたので気になる方は挑戦してみてください。
PVアクセスランキング にほんブログ村