Trouble With Lua Scripting

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

  1. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    Hey everyone today i gave a go at Lua Scripting followed the HTML box tutorial to the fullest and nothing happened in turn once i was finished, here is my scrip maybe someone could correct what i am doing wrong thanks
    -- 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)
    if (event== "introtext") then
    SysCall ( "ScenarioManager:ShowInfoMessageExt", "Title of the box", "introtext.html", 0, MSG_VCENTRE + MSG_CENTRE, MSG_REG, TRUE );
    end
    end

    function TestCondition(condition)
    end



    Here is the Html
    <html>
    <body bgcolor="#ff0000">
    <font color="#ffff00" face="Arial" size="3">
    <table>
    <tr>
    <td><img src="../BNSF.png" width="128" height="128"></td>
    <td>
    <p><b>Welcome to this scenario</b></p>
    <p>Wait for a WB <i>finish</i> to take the siding</p>
    </td>
    </tr>
    </table>
    </font>
    </body>
    </html>
     
  2. dunkrez

    dunkrez Well-Known Member

    Joined:
    May 2, 2019
    Messages:
    1,084
    Likes Received:
    887
    I will come back and help you along with this, but we're going to need more detail please mate :)
     
    • Like Like x 1
  3. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    Okay thanks, this is all i got lol, what more do you need? :)
     
  4. pgdlrailworksl

    pgdlrailworksl New Member

    Joined:
    Jul 10, 2020
    Messages:
    11
    Likes Received:
    10
    Are you missing some lines from the end of the Lua you posted above?
    This is copied from a working scenario.
    Intromessage.html is in the sub-folder EN


    -- 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
    MT_ALERT = 1

    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()
    DisplayRecordedMessage("IntroText")
    end


    function OnEventIntroText()
    DisplayRecordedMessage("IntroText");
    end





    function DisplayRecordedMessage( messageName )
    SysCall("RegisterRecordedMessage", "StartDisplay" .. messageName,
    "StopDisplay" .. messageName, 1);
    end

    function StartDisplayIntroText()
    SysCall ( "ScenarioManager:ShowInfoMessageExt", "d7ef8a27-97c0-4da5-9dc9-dbd833d1a13d",
    "intromessage.html", 0, MSG_VCENTRE + MSG_CENTRE, MSG_LRG, TRUE );
    end



    function StopDisplayIntroText()
    end
     
    • Like Like x 1
  5. upstatenyrailfan

    upstatenyrailfan Member

    Joined:
    Jun 5, 2020
    Messages:
    45
    Likes Received:
    22
    Thanks look like i was missing quite a bit
     

Share This Page