1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice
  3. Before reporting issues or bugs, please check the up-to-date Bug Reporting Thread for the current version.
    0.37 Bug Reporting thread
    Solutions and more information may already be available.

sharedModules are not loaded on the first run of a flowgraph

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by Hash, Jun 22, 2022.

  1. Hash

    Hash
    Expand Collapse

    Joined:
    Apr 21, 2022
    Messages:
    11
    When a flowgraph is run for the first time after the game is launched, the global variable gameplay_traffic is all shared modules are nil when accessed inside of a "Custom Lua" node.

    This includes core_weather, core_trailerRespawn, util_richPresence, core_checkpoints, core_collectables, gamplay_traffic, gameplay_walk, core_multiSpawn.
    This list is taken from \lua\ge\main.lua [lines 205-207]



    Steps to reproduce bug:
    1. Launch the game. If the game is already open, restart the game.
    2. Load a flowgraph with a custom lua node where the global variable "gameplay_traffic" is used
    3. Start the flowgraph
    4. "gameplay_traffic" cannot be used
    5. Stop and start the flowgraph
    6. "gameplay_traffic" can be used normally



    Example:


    The code inside of the custom lua node is taken directly from the \gameplay\missionTypes\garageToGarage\garage.flow.json flowgraph.
    Code:
    self.pinOut.value.value = math.min(self.pinIn.max.value,gameplay_traffic.getAmountFromSettings())
    self.pinOut.flow.value = true
    The flowgraph and log files are attached
    --- Post updated ---
    Oh that's weird. The file name of the attached flowgraph changed. I guess you will have to add back the missing "." if you want to use that.
     

    Attached Files:

    #1 Hash, Jun 22, 2022
    Last edited: Jun 23, 2022
  2. Hash

    Hash
    Expand Collapse

    Joined:
    Apr 21, 2022
    Messages:
    11
    Hello I have found a rather lazy workaround.


    Inside the Custom Lua node is:
    Code:
    work:
    self.pinOut.error.value = gameplay_traffic == nil
    self.pinOut.ready.value = not self.pinOut.error.value
    
    _executionStarted:
    self.pinOut.ready.value = false
    self.pinOut.error.value = false
     
    #2 Hash, Jun 23, 2022
    Last edited: Jun 23, 2022
  3. TStabbert

    TStabbert
    Expand Collapse
    BeamNG Team

    Joined:
    Nov 28, 2016
    Messages:
    66
    Hello :)
    you can try to call this function either in _executionStarted() or work():
    Code:
    refreshExtensions()
    That will update all the extension references from the main lua VM to the envelope the CustomLua node uses.
     
  4. Hash

    Hash
    Expand Collapse

    Joined:
    Apr 21, 2022
    Messages:
    11
    Thanks TStabbert!
    I added refreshExtensions() to my some of my nodes and they seem happy now.

    I like your flowgraph thing btw. It's nice that all the documentation is built in.
    I still hate lua though. I get why it's good for game engines, but man I hate lua so much.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice