Cinematic Camera

Discussion in 'General Discussion' started by upstatenyrailfan, Oct 10, 2020.

  1. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    So i'm currently working on a scenario and i want to utilize the cinematic camera in this case i named my trigger function Intro. I also have 3 key frames what would i enter in for the LUA script?
     
  2. Cameron's Gaming

    Cameron's Gaming Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    2,099
    Likes Received:
    2,754
    Have you already set up the camera?
     
    • Like Like x 1
  3. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    yes the camera sequence has been setup. and is functional i just need to script it for it to work. I'm typically not good with lua scripit :(
     
  4. Cameron's Gaming

    Cameron's Gaming Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    2,099
    Likes Received:
    2,754
    The camera needs to be named, firstly, using this small box. upload_2020-10-11_16-11-7.png

    The player's first instruction must be a trigger instruction, name it something (small box above the large one). upload_2020-10-11_16-3-7.png

    This is the LUA script you need:

    -- true/false defn
    FALSE = 0
    TRUE = 1
    -- condition return values
    CONDITION_NOT_YET_MET = 0
    CONDITION_SUCCEEDED = 1
    CONDITION_FAILED = 2
    -- Message types
    MT_INFO = 0 -- large centre screen pop up
    MT_ALERT = 1 -- top right alert message

    MSG_TOP = 1
    MSG_VCENTRE = 2
    MSG_BOTTOM = 4
    MSG_LEFT = 8
    MSG_CENTRE = 16
    MSG_RIGHT = 32

    MSG_SMALL = 0
    MSG_REG = 1
    MSG_LRG = 2

    function OnEvent(event)
    return _G["OnEvent" .. event]();
    end
    function TestCondition(condition)
    return _G["TestCondition" .. event]();
    end

    function OnEventStart()
    SysCall("ScenarioManager:LockControls")
    SysCall("CameraManager:ActivateCamera", "startcamera01", 0)
    end

    For the purposes of this, the trigger instruction was called "Start", and the camera was named "startcamera01".

    Alternatively, I was just reminded that I did a (arguably very long-winded) tutorial on this sort of thing a few years ago: (skip to 15:08 if it doesn't automatically take you there). The video concerns multiple camera shots, if you're doing more than one.
     
    • Helpful Helpful x 1
  5. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    It works! thanks a bunch, one quick question do you also have a HTML lua script file plan on saving this for future work
     
  6. Cameron's Gaming

    Cameron's Gaming Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    2,099
    Likes Received:
    2,754
    A HTML LUA script?
     
    • Like Like x 1
  7. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    Oh and how can i unlock the controls?
     
  8. Cameron's Gaming

    Cameron's Gaming Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    2,099
    Likes Received:
    2,754
    oh damn I forgot about that:

    function OnEventStart()
    SysCall("ScenarioManager:LockControls")
    SysCall("CameraManager:ActivateCamera", "startcamera01", 0)
    SysCall("ScenarioManager:TrigerDeferredEvent", "UnlockControls", #)
    end

    function OnEventUnlockControls()
    SysCall("ScenarioManager:UnlockControls")
    end

    replace the # with however long the camera sequence is in seconds.

    I have a template LUA script kicking around somewhere. I'll try and find it.
     
    • Helpful Helpful x 1
  9. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    Yep HTML, once the cinematic completes i can't ,move or control the train am i missing any more lua?
     
  10. Cameron's Gaming

    Cameron's Gaming Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    2,099
    Likes Received:
    2,754
    Yes, that'll be because I forgot to include the unlock controls command.

    I've found the template, but I've had to upload it in .txt format because it (understandably) wouldn't let me upload it as a LUA script. Remember to save it as a LUA file if you use it. Feel free to use & distribute it.

    There is a way of using HTML in LUA scripts for messages: http://trainsimlive.blogspot.com/2015/02/ts2015-scenario-scripting-in-lua-part-3.html
     

    Attached Files:

    • Like Like x 1
  11. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    Okay so i entered 12 seconds watched the sequence entered it and once it completes i can't even close the game i'm stuck on a external view
     
  12. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    this is what i currently have
    -- true/false defn
    FALSE = 0
    TRUE = 1
    -- condition return values
    CONDITION_NOT_YET_MET = 0
    CONDITION_SUCCEEDED = 1
    CONDITION_FAILED = 2
    -- Message types
    MT_INFO = 0 -- large centre screen pop up
    MT_ALERT = 1 -- top right alert message

    MSG_TOP = 1
    MSG_VCENTRE = 2
    MSG_BOTTOM = 4
    MSG_LEFT = 8
    MSG_CENTRE = 16
    MSG_RIGHT = 32

    MSG_SMALL = 0
    MSG_REG = 1
    MSG_LRG = 2

    function OnEvent(event)
    return _G["OnEvent" .. event]();
    end
    function TestCondition(condition)
    return _G["TestCondition" .. event]();
    end

    function OnEventStart()
    SysCall("ScenarioManager:LockControls")
    SysCall("CameraManager:ActivateCamera", "startcamera01", 0)
    end
    function OnEventStart()
    SysCall("ScenarioManager:LockControls")
    SysCall("CameraManager:ActivateCamera", "startcamera01", 0)
    SysCall("ScenarioManager:TrigerDeferredEvent", "UnlockControls", 12)
    end

    function OnEventUnlockControls()
    SysCall("ScenarioManager:UnlockControls")
    end
     
  13. Cameron's Gaming

    Cameron's Gaming Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    2,099
    Likes Received:
    2,754
    remove this bit
    upload_2020-10-11_18-5-4.png
    Other than that, it looks fine, but you may wish to add a statement to change the camera to the cab and display a message (just makes it look cleaner)
     
  14. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    -- true/false defn
    FALSE = 0
    TRUE = 1
    -- condition return values
    CONDITION_NOT_YET_MET = 0
    CONDITION_SUCCEEDED = 1
    CONDITION_FAILED = 2
    -- Message types
    MT_INFO = 0 -- large centre screen pop up
    MT_ALERT = 1 -- top right alert message

    MSG_TOP = 1
    MSG_VCENTRE = 2
    MSG_BOTTOM = 4
    MSG_LEFT = 8
    MSG_CENTRE = 16
    MSG_RIGHT = 32

    MSG_SMALL = 0
    MSG_REG = 1
    MSG_LRG = 2

    function OnEvent(event)
    return _G["OnEvent" .. event]();
    end
    function TestCondition(condition)
    return _G["TestCondition" .. event]();
    end

    function OnEventStart()
    SysCall("ScenarioManager:LockControls")
    SysCall("CameraManager:ActivateCamera", "startcamera01", 0)
    SysCall("ScenarioManager:TrigerDeferredEvent", "UnlockControls", 12)
    end

    function OnEventUnlockControls()
    SysCall("ScenarioManager:UnlockControls")
    end


    So i got this now and still nothing save scenario and nothing happens
     
  15. Cameron's Gaming

    Cameron's Gaming Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    2,099
    Likes Received:
    2,754
    Have you compiled it in the editor?

    Save the script, then in TS, press this:
    upload_2020-10-11_18-25-31.png
    Click reload then compile/generate MD5
     

Share This Page