Get Current Level Name in Lua or JS

Discussion in 'Programming' started by angelo234, Nov 23, 2020.

  1. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    I'm making a UI app that needs the name of the current map being played on and so is there a function out there? Thanks in advance!
     
  2. Alex_Farmer557

    Alex_Farmer557
    Expand Collapse

    Joined:
    Dec 28, 2016
    Messages:
    3,541
    • Like Like x 1
  3. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    Alright that was helpful and I got it to work, thank you! :)
     
  4. StinchinStein

    StinchinStein
    Expand Collapse

    Joined:
    Jul 16, 2014
    Messages:
    754
    Posting this for anyone wondering how to do this without going to another thread to search for it.
    You can use this in the GameEngine Lua to figure out the level name:

    Code:
    local missionFile = getMissionFilename()
    local levelDir, filename, ext = path.split(missionFile)
    local levelName = levelDir:sub(9, -2)
    
    print(levelName) -- "east_coast_usa"
     
    • Like Like x 1
  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