Unable to load flowgraph mission using BeamNGpy

I created a mod which contains a custom flowgraph mission, but I am unable to load the mission using BeamNGpy.

Context:

My mission is stored in the directory: C:\Users\user_name\AppData\Local\BeamNG\BeamNG.tech\current\mods\unpacked\mod_name\gameplay\missions\west_coast_usa\flowgraph\005-mission_name

This directory contains the files info.json, flowgraph.flow.json, and a few prefabs.

As recommended by the Scenario Example, I also saved my mission using “Save as Scenario”. This created the directory:

C:\Users\user_name\AppData\Local\BeamNG\BeamNG.tech\current\gameplay\missions\west_coast_usa\flowgraph\005-mission_name

which contains the files mission_name.json and mission_name.flow.json.

Issue:

BeamNGpy does not recognize either of these formats of the mission.

bng = BeamNGpy(‘localhost’, 25252, home=‘F:/BeamNG.tech.v0.38.3.0’, user=‘C:/Users/user_name/AppData/Local/BeamNG/BeamNG.tech’)

bng.open()

scenarios = bng.get_scenarios()

print(scenarios[“west_coast_usa”]

The list returned by this code does not include the custom scenario. In addition, if I open the scenario from within the simulation and then call:

bng.get_current_scenario()

I receive the following error:

beamngpy.logging.BNGValueError: Scenario ‘/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/info.json’ not found.

Furthermore, I attempted to load the scenario manually using this code:

scenario = Scenario(‘west_coast_usa’, ‘mission_name’, ‘/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/info.json’)

bng.scenario.load(scenario)

And recieved the error: “Scenario not found”

I tried several permutations of file paths and scenario names, all of which produced the same error. Here is a list of the commands I tried:

scenario = Scenario(‘west_coast_usa’, ‘mission_name’, ‘/mods/unpacked/mod_name/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/info.json’)

scenario = Scenario(‘west_coast_usa’, ‘missions.west_coast_usa.flowgraph.mission_name’, ‘/mods/unpacked/mod_name/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/info.json’)

scenario = Scenario(‘west_coast_usa’, ‘missions.west_coast_usa.flowgraph.mission_name.title’, ‘/mods/unpacked/mod_name/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/info.json’)

scenario = Scenario(‘west_coast_usa’, ‘mission_name’, ‘/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/info.json’)

scenario = Scenario(‘west_coast_usa’, ‘missions.west_coast_usa.flowgraph.mission_name’, ‘/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/info.json’)

scenario = Scenario(‘west_coast_usa’, ‘missions.west_coast_usa.flowgraph.mission_name.title’, ‘/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/info.json’)

scenario = Scenario(‘west_coast_usa’, ‘mission_name’, ‘/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/mission_name.json’)

scenario = Scenario(‘west_coast_usa’, ‘missions.west_coast_usa.flowgraph.mission_name’, ‘/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/mission_name.json’)

scenario = Scenario(‘west_coast_usa’, ‘missions.west_coast_usa.flowgraph.mission_name.title’, ‘/gameplay/missions/west_coast_usa/flowgraph/005-mission_name/mission_name.json’)

The mission works completely fine from within the simulator, but BeamNGpy seems completely unable to recognize it.

Hi @mHerring09,

did you check the “Is Available as Scenario” checkbox in the Mission Editor? BeamNGpy currently only sees missions which are also available as scenarios.

I was able to successfully load this empty mission with:

scenario = Scenario(level='hirochi_raceway', name='Name2', path='/gameplay/missions/hirochi_raceway/flowgraph/001-Name/info.json')
beamng.scenario.load(scenario)

And my mission files are located in %localappdata%\BeamNG\BeamNG.tech\current\gameplay\missions\hirochi_raceway\flowgraph\001-Name.

@aivora Thanks for the help.

I did have “Is Available as Scenario” checked. However, my mission is part of a mod and is thus located in the /current/mods/unpacked/mod_name/gameplay folder. I discovered that moving my mission to the ordinary gameplay folder (/current/gameplay) allowed me to load the scenario. So perhaps there is a bug which prevents BeamNGpy from accessing the mods/unpacked folder.

Unfortunately, I ran into a greater issue. When loading a mission this way, the mission isn’t actually loaded at all. I reproduced the issue using these steps:

  1. Enter world editor and create a new flowgraph mission.
  2. Close BeamNG
  3. Open BeamNG from python
  4. Load the mission using the command you provided

Rather than loading the mission, the map is loaded and a car is spawned like in free roam. The scenario.load command hangs indefinitely (I let it run for 10 minutes with no results). You can of course drive to the mission marker and start the mission that way, but I would like to load it using python.

Do you think these two issues are bugs? Or am I missing something?