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.35 Bug Reporting thread
    Solutions and more information may already be available.

SOLVED [World Editor] Level can't be saved after a few minutes

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by stuffi3000, Sep 21, 2024.

  1. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    Hello everyone,

    Since this update I've had a recurring and very anoying problem in the World Editor: after just a couple of minutes of using the World Editor, the asset browser window disappears and the level does not save properly anymore. I'm stuck in the World Editor (can't close it with F11 or by going into the menu), and while I can click on safe and press CTRL+S, the files in the level folder aren't modified. It also doesn't say "Backup saved also" anymore either.
    This has already let me to lose map making progress multiple times and it's really frustrating.

    I have unloaded all my mods and the problem persists.

    The beamng.log shows the following error:
    707.95639|E|GameEngineLua:Exception| lua/common/utils.lua:960: attempt to concatenate local 'levelName' (a nil value)
    =============== Stack Traceback >> START >>
    (1) metamethod C function '__concat'
    (2) Lua field 'getPathLevelMain' at file 'lua/common/utils.lua:960'
    levelName = nil
    (*temporary) = C function: 0x022f167297a0
    (*temporary) = string[15]: "main.level.json"
    (*temporary) = string[8]: "/levels/"
    (*temporary) = nil
    (*temporary) = string[16]: "/main.level.json"
    (*temporary) = string[54]: "attempt to concatenate local 'levelName' (a nil value)"
    (3) Lua upvalue 'saveLevelAs' at line 145 of chunk 'lua/ge/extensions/editor/api/core.lua'
    levelPath = string[41]: "/settings/editor/autosaves/ebr2021sv/0001"
    levelName = nil
    (*temporary) = C function: 0x022f167295f8
    (*temporary) = string[41]: "/settings/editor/autosaves/ebr2021sv/0001"
    (4) Lua field 'autoSaveLevel' at line 166 of chunk 'lua/ge/extensions/editor/api/core.lua'
    oldLevelPath = string[41]: "/settings/editor/autosaves/ebr2021sv/0001"
    folderName = string[4]: "0001"
    oldDirty = boolean: true
    counter = number: 1
    path = string[41]: "/settings/editor/autosaves/ebr2021sv/0001"
    (5) Lua local 'func' at line 121 of chunk 'lua/ge/extensions/editor/autoSave.lua'
    dtReal = number: 0.0165304
    dtSim = number: 0.0165
    dtRaw = number: 0.0168306
    (6) Lua field 'hook' at line 715 of chunk 'lua/common/extensions.lua'
    funcName = string[11]: "onEditorGui"
    funcList = table: 0x022f6b2537a0 {1:function: 0x022f6ae89b28, 2:function: 0x0230ca933d80, 3:function: 0x022f168fe5a0 (more...)}
    (for generator) = C function: builtin#6
    (for state) = table: 0x022f6b2537a0 {1:function: 0x022f6ae89b28, 2:function: 0x0230ca933d80, 3:function: 0x022f168fe5a0 (more...)}
    (for control) = number: 63
    _ = number: 63
    func = Lua function '?' (defined at line 109 of chunk lua/ge/extensions/editor/autoSave.lua)
    (7) Lua field 'presentGui' at line 447 of chunk 'lua/ge/extensions/editor/api/gui.lua'
    dtReal = number: 0.0165304
    dtSim = number: 0.0165
    dtRaw = number: 0.0168306
    io = cdata: (...)
    (8) Lua local 'func' at line 31 of chunk 'lua/ge/extensions/editor/mainUpdate.lua'
    dtReal = number: 0.0165304
    dtSim = number: 0.0165
    dtRaw = number: 0.0168306
    (9) Lua field 'hook' at line 715 of chunk 'lua/common/extensions.lua'
    funcName = string[8]: "onUpdate"
    funcList = table: 0x022fe2ae8a80 {1:function: 0x022f6b94a218, 2:function: 0x022f16989968, 3:function: 0x022f1747c6e8 (more...)}
    (for generator) = C function: builtin#6
    (for state) = table: 0x022fe2ae8a80 {1:function: 0x022f6b94a218, 2:function: 0x022f16989968, 3:function: 0x022f1747c6e8 (more...)}
    (for control) = number: 16
    _ = number: 16
    func = Lua function '?' (defined at line 22 of chunk lua/ge/extensions/editor/mainUpdate.lua)
    (10) Lua function 'update' at file '/lua/ge/main.lua:536' (best guess)
    dtReal = number: 0.0165304
    dtSim = number: 0.0165
    dtRaw = number: 0.0168306
    --------------- << END <<

    Any help would be appreciated.
     
  2. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    492
    It looks like the code can’t read your level name or path. Strange. Do you have your level in the levels folder under your user folder?
     
  3. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    Yeah, and the weird part about it is that it can indeed save the level, but only in the first couple of minutes.
    It is in the user folder. I've been working like this for over a year, without running into this issue...
     
  4. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    I managed to apparently fix the issue by replacing lines 141 to 174 in ge\extensions\editor\api\core.lua with the following code (changes in bold):
    -- Save the level's scene tree to the specified path.
    local function saveLevelAs(levelPath)
    editor.levelPath = levelPath
    local levelName = editor.getLevelName()
    setMissionFilename(path.getPathLevelMain(levelName))
    editor.saveLevel()
    end

    --- Save a copy of the level's scene tree to an autosave folder
    local function autoSaveLevel()
    if editor.getLevelName() == "" or not editor.getLevelName() then return end
    local oldLevelPath = editor.levelPath
    local folderName
    local oldDirty = editor.dirty
    editor.dirty = true

    if editor.getPreference("files.autoSave.counter") > editor.getPreference("files.autoSave.maxAutoSaveCountPerSession") then
    editor.setPreference("files.autoSave.counter", 1)
    end

    local counter = editor.getPreference("files.autoSave.counter")

    folderName = string.format("%04d", counter)
    local path = "/settings/editor/autosaves/" .. editor.getLevelName() .. "/" .. folderName
    editor.autosavingNow = true
    saveLevelAs(path)
    editor.autosavingNow = false
    editor.levelPath = oldLevelPath
    local levelName = editor.getLevelName()
    setMissionFilename(sanitizePath('/levels/'..levelName..'/main.level.json'))

    counter = counter + 1
    editor.setPreference("files.autoSave.counter", counter)
    editor.dirty = oldDirty
    end

    It really had issues with the level name and I don't understand why.

    I managed to narrow it down to autosave being the problem before implementing the "fix" above. I couldn't test it a lot today but it seems to hold. If the issue presents itself again I will update this thread. Marked this as solved for now.
     
  5. Barbent Servo GT

    Barbent Servo GT
    Expand Collapse

    Joined:
    Jun 4, 2023
    Messages:
    643
    I would like to know what is your level name? I encountered problems with level names containing "-". E.g. "test-level". This happens since the 0.33.0 update. The name "test_level" makes no problems at all. Seems they changed some path and naming functionality internally.
     
  6. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    Initially my level name was "EBR2021SV". I changed it to "ebr_sv" to test if that would fix it, but it didn't. I kept it for now though.
     
  7. itsDave

    itsDave
    Expand Collapse

    Joined:
    Jan 21, 2025
    Messages:
    1
    I've been having this issue for months now and your changes to ge\extensions\editor\api\core.lua fixed the issue for me. Thanks for figuring it out!

    In case a developer decides to take a look at this:
    I'll note that I had the issue with any level I opened in the editor, whether it was an official map, mod from the repo, or custom map. I don't remember exactly when it started, but it was at least January 2024. I still had the issue on version 0.34.2.
     
  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