Problem 'clbk_loadstateex' not working for me

johnnymanly

Donator
Donator
Joined
Mar 17, 2008
Messages
179
Reaction score
116
Points
43
Location
Southwest Pennsylginia
Website
sites.google.com
I'm running 2024-rc1, working on a multistage vessel, and I'm having trouble resuming from the "Current state" scenario.
I'm saving and reading like this:
Code:
function clbk_loadstateex(scn, vs2)

  local match = {}

  for line in scenario_lines(scn) do
    if scenario_line_match(line, "CONFIGURATION %d", match) then
      configuration = match.res[1]
    else
      vi:parse_scenario_line_ex(line, vs2)
    end
  end

end

function clbk_savestate(scn)

  oapi.writescenario_string(scn, "CONFIGURATION", tostring(configuration))

end
I have 4 configurations but it always resumes on configuration 0. It writes the correct configuration just fine.
I hope I explained this well enough. :unsure:
Attached is a copy of the Lua file in case anyone wants to have a look.
 

Attachments

Your code looks OK, I tested it (commenting the add_mesh lines) and it runs OK too. If I set "CONFIGURATION 3" in the current scenario, I get "config 3" if I add this in clbk_loadstateex :
oapi.dbg_out("config "..configuration)

Maybe it's overwritten somewhere else?
 
I was going to leave this go and move my project to a DLL but I'd really like to know where I'm going wrong.
The sim says that it's opening at the right configuration but it's not. It always starts at configuration 0 (clbk_setclasscaps).
Attached is a simple script, meshes, and scenario if anyone wants to have a look.
 

Attachments

I find nothing wrong with the configuration loading, however looks like there is something amiss in your loading sequence.
Adding this at the end of the clbk_loadstateex function makes things better :
Code:
      if configuration == 1 then
          two()
      elseif configuration == 2 then
          three()
      end
 
Back
Top