mrSkortch / MissionScriptingTools

Mission Scripting Tools for Digital Combat Simulator
GNU General Public License v3.0
195 stars 42 forks source link

Functions based on "ME" databases do not work for dynamically spawned groups because "ME" databases are not updated in updateDBTables() #76

Closed plemtom closed 1 year ago

plemtom commented 1 year ago

I am not completely positive about it but I reviewed the code and it seems this way. Also what do we need separate "ME" databases for on top of regular ones if it's regular DBs that are being regularly updated?

mrSkortch commented 1 year ago

ME databases are specifically there as copy of the databases as the mission was saved in the editor. They aren't supposed to be used with dynamically added groups. Think of it like this, you have a group you placed in the editor, a few units die, and for whatever reason you decide to despawn the group. If you spawn the group later, keep the group name/id the same, but don't spawn the dead units in it, then updateDBTables and consequently mist.DBs.groupsByName, etc will be updated to reflect the new group contents. If you wanted to "repair" the group by respawning it in its entirety you could use a reference from mist.DBs.MEgroupsByName.

Basically had to choose between keeping an original copy or making a function that returned the same or similar format on request.

plemtom commented 1 year ago

Roger that. Makes sense. Some functions use ME DBs to find groups though. Like getGroupRoute for example. Is that intentional? I tried to use those with dynamically spawned groups and they just return alert that group is not found in ME database.

Original groups in ME DBs also have original routes? Perhaps there should be another set of functions to work with the living DB... dunno... I think I will just try that for now as a workaround.

mrSkortch commented 1 year ago

getGroupRoute returns the route table as defined in the editor. There is no scripting function that returns a route currently assigned to a group. Thus it checks the ME DB to verify the group exists in the miz file. Currently mist doesn't save the route pushed with mist.goRoute or if you spawn a group with a route table. If you create your own route there is nothing stopping you from saving that somewhere to access at a later point similar to getGroupRoute.

plemtom commented 1 year ago

Then it seems this is not an issue. Closing. Thanks for helping me understand this stuff.