Jump to content

SPGG - Simple Persistent Ground Groups Script


Go to solution Solved by Kanelbolle,

Recommended Posts

Posted (edited)

OK, the save file is being populated now thank you very much for your help.

It appears I had edited the file inside the open beta install and not the standalone server install by mistake!

I assume that, in order to reset the save I just have to delete the save file?  Or rename it in favor of a fresh one?  Or do I have to always run spgg.clearSavefile()?

Thanks again!

Edited by Chad Vader
Posted

Ive just played a mission and destroyed some units.. then reloaded the mission and its not saved the state...

The save file is being populated though, I can see the modified date changed.

Posted
24 minutes ago, Chad Vader said:

OK, the save file is being populated now thank you very much for your help.

It appears I had edited the file inside the open beta install and not the standalone server install by mistake!

I assume that, in order to reset the save I just have to delete the save file?  Or rename it in favor of a fresh one?  Or do I have to always run spgg.clearSavefile()?

Thanks again!

 

Don't delete the save file, delete the content of the file or run "spgg.clearSavefile()" in the mission.

 

Quote

Ive just played a mission and destroyed some units.. then reloaded the mission and its not saved the state...

The save file is being populated though, I can see the modified date changed.

The timer to save is every 60 min. If you want to force a save you can run "spgg.save()" in the mission.

It is explained in "Step 4 - Saving groups" on page 8 in the readme.

  • Like 1
Posted

Ive changed the timer to every 1 min to test it.

I can see many backup saves being created and the SPGG_savefile.lua modified time changing every minute.

But when I load the mission back up, its not saved.  Do I need to be doing anything else to load the mission?

Posted (edited)
2 minutes ago, Chad Vader said:

Ive changed the timer to every 1 min to test it.

I can see many backup saves being created and the SPGG_savefile.lua modified time changing every minute.

But when I load the mission back up, its not saved.  Do I need to be doing anything else to load the mission?

See "Step 3 - How to SPAWN units in your mission" Page 7 in the readme. (should be step 4, but misspelled)

Edited by Kanelbolle
Posted (edited)

Spawn units?

All my units are already preprogramed in the mission editor.  If I spawn the units, wont they be added in addition to the existing units?

Im looking at this thinking its not possible to use it unless you are programmatically spawning units in at mission start.....

 

Edited by Chad Vader
Posted
40 minutes ago, Chad Vader said:

Spawn units?

All my units are already preprogramed in the mission editor.  If I spawn the units, wont they be added in addition to the existing units?

Im looking at this thinking its not possible to use it unless you are programmatically spawning units in at mission start.....

 

 

Creating a mission with a save script is different from a regular mission.

Example you can sett all the units you have to "Late Activation" and use the "- FLAG or LUA variable for tracking if the mission is loaded in a persistent state."

See the example missions included, there are units in the trigger list that only activate if the mission is started without a save. (Flag "spgginitalstart" is true)

 

 

  • Kanelbolle changed the title to SPGG - Simple Persistent Ground Groups Script
Posted
5 minutes ago, PaulSummer said:

I only need CTLD spawns to be saved no other units on  the map in our missions  -  is this possible ?

Many thanks

Hi!

Yes this is possible. You can name all other units with a starting name that is exuded from the saving function.

See SPGG.lua for this table:

-- All groups names beginning with strings in this array will be excluded from saveing.
_tblExcludeGroupName = {
"AF_",
"StandAlone_",
"SA_Convoy_",
"Clone_",
"Build_",

}

 

All you have to do is add a starting string you want to exlude, like one of the examples already in the list and name your Groups according to it.

Example if you use the list above and add a group named "Clone_12345_Group-1", the group will be exuded from being saved.

  • Like 1
Posted (edited)

Perfect many thanks, also is there a way to just save Blue and not Red or would that be the same add in a prefix to all red units and exclude them  ? 

Basically I am just trying to save blue CTLD units nothings else its on a Foothold Mission that I have modified and added CTLD and trying to just save those units / Farps - as Foothold saves the zones and units in the zones and is using Mist to spawn.

If that makes sense  🙂

Edited by PaulSummer
Posted (edited)
21 minutes ago, PaulSummer said:

Perfect many thanks, also is there a way to just save Blue and not Red or would that be the same add in a prefix to all red units and exclude them  ? 

Basically I am just trying to save blue CTLD units nothings else its on a Foothold Mission that I have modified and added CTLD and trying to just save those units / Farps - as Foothold saves the zones and units in the zones and is using Mist to spawn.

If that makes sense  🙂

 

You can do the exlude names way or you can just not spawn the red units back..

Example if you want to spawn back all units you run this at the start of the mission:

spgg.spawnBlueGroundGroup()
spgg.spawnRedGroundGroup()
spgg.spawnBlueStaticObject()
spgg.spawnRedStaticObject()
spgg.spawnBlueSeaGroup()
spgg.spawnRedSeaGroup()
spgg.findAndAddSamSystems()

 

If you want only Blue units you just do this instead:

spgg.spawnBlueGroundGroup()
spgg.spawnBlueStaticObject()
spgg.spawnBlueSeaGroup()
spgg.findAndAddSamSystems()

Or just: 
spgg.spawnBlueGroundGroup()
spgg.findAndAddSamSystems()

Edited by Kanelbolle
Posted

Just checking if i use the below and add in spgg.save()  to the function it should force a save  ? i just wanted to be able to force a save now and again just in case a server restart .

 
function ctld.listFOBS(_args)

    local _msg = "FOB Positions:"

    local _heli = ctld.getTransportUnit(_args[1])
	spgg.save()
    if _heli == nil then

        return -- no heli!
    end

    -- get fob positions

    local _fobs = ctld.getSpawnedFobs(_heli)

    -- now check spawned fobs
    for _, _fob in ipairs(_fobs) do
        _msg = string.format("%s\nFOB @ %s", _msg, ctld.getFOBPositionString(_fob))
    end

    if _msg == "FOB Positions:" then
        ctld.displayMessageToGroup(_heli, "Sorry, there are no active FOBs!", 20)
    else
        ctld.displayMessageToGroup(_heli, _msg, 20)
    end
end

 

Posted
1 hour ago, PaulSummer said:

Just checking if i use the below and add in spgg.save()  to the function it should force a save  ? i just wanted to be able to force a save now and again just in case a server restart .

 
function ctld.listFOBS(_args)

    local _msg = "FOB Positions:"

    local _heli = ctld.getTransportUnit(_args[1])
	spgg.save()
    if _heli == nil then

        return -- no heli!
    end

    -- get fob positions

    local _fobs = ctld.getSpawnedFobs(_heli)

    -- now check spawned fobs
    for _, _fob in ipairs(_fobs) do
        _msg = string.format("%s\nFOB @ %s", _msg, ctld.getFOBPositionString(_fob))
    end

    if _msg == "FOB Positions:" then
        ctld.displayMessageToGroup(_heli, "Sorry, there are no active FOBs!", 20)
    else
        ctld.displayMessageToGroup(_heli, _msg, 20)
    end
end

 

Yes, that works.

  • Like 1
Posted

Update v021:

  • Changed the script from 3 files to 1 file. (Installation is changed, please see the installation part in the readme!)
  • Updated example mission files with drawings and briefing text.
  • Made Backup saving optional. (Default off)
  • Added check if save file is present or not. You can now just delete the save file if you want to reset the save file.
  • Like 1
Posted (edited)
4 hours ago, PaulSummer said:

Any idea why it does not Save a FARP ?  i added FARP to CTLD but it does not seem to save it ?

Cheers

 

Hi!

FARP's can not be retrived with the function "coalition.getStaticObjects".
DCS does not support the retrial of this object if it is spawned mid game.

FARPS only show up in "env." and this can not be modified after mission start.
This is also the same reason i can not save the routs and tasks of units after spawning a unit mid game, it is just not supported by DCS.

 

You can place out Static objects on the map in ME and get the list of objects with the below code and see if the object you placed is possible to save.
Just put it in a Trigger in the ME with a action "DO SCRIPT" with a "TiME MORE" condition.

-- 1 = RED, 2 = Blue
local coa = 2

for i, so in pairs(coalition.getStaticObjects(coa)) do
	
	if so ~= nil then
		
		local _SoName = StaticObject.getName(so)
			
		if (StaticObject.getByName(_SoName)) and (StaticObject.isExist(so)) then

			env.info('-- Found Static Object: ' .. _SoName)
			trigger.action.outText("Found Static Object: " .. _SoName, 20)

		end
	end

end

 

Edited by Kanelbolle
  • Like 1
  • 1 month later...
Posted

Update v022:

  • Added saving of Group and Unit Id of units. You can now spawn them back with the same ID. (See: spgg.ReuseID) (WARNING : Do not turn on if you have a old save file. Start the mission first with "false", let spgg save. Then change this to "true")
  • Included the Natural groups in saving process. See readme for commands.
  • Changes to save function to use less code.
  • 3 months later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...