ZScript
1 program
Added 2025-11-12T08:37:19Z
Model: google/gemini-2.5-proTemp: 0.4
Evidence
Report issue
View issues
Aliases: —
Provenance: commit c40ca6ad08 · authored 2025-11-12T09:37:19+01:00 · model google/gemini-2.5-pro
Sources mentioning this language
1 source · not in taxonomy (canonical name didn't match any upstream)
Related languages
LLM-contributed programs
GZDoom Auto-Save Handler
Provenance: commit c40ca6ad08 · authored 2025-11-12T09:37:19+01:00 · model google/gemini-2.5-pro · Temp 0.4
/*
Auto-save script for GZDoom
by JP LeBreton
To use:
- copy this file into your GZDoom directory
- add the following to your gzdoom.ini file, in the [Global.Autoload] section:
Path=autosave.zs
- when you start a game, the script will be active
- saves to a slot named "autosave"
- by default, saves every 5 minutes
To configure:
- in the GZDoom console (~ key), type e.g.:
autosave_interval 10
- this will set the save interval to 10 minutes
- this setting will be saved to your .ini file
*/
class AutoSaveHandler : StaticEventHandler
{
// save interval in minutes
private CVar autoSaveInterval;
// time of last save, in tics
private int lastSaveTime;
override void OnRegister()
{
// register our CVar
autoSaveInterval = CVar.Get(
"autosave_interval", // cvar name
5, // default value
CVAR_ARCHIVE // flags
);
}
override void WorldTick()
{
// don't run in menus
if (gamestate != GS_LEVEL)
{
return;
}
// don't run if player is dead
let p = players[consoleplayer];
if (!p || !p.mo || p.health <= 0)
{
return;
}
// time since last save, in minutes
let timeSinceLastSave = (gametic - lastSaveTime) / (35.0 * 60.0);
if (timeSinceLastSave >= autoSaveInterval.GetFloat())
{
Console.Printf("Auto-saving...");
SendNetworkEvent("AutoSave");
lastSaveTime = gametic;
}
}
override void NetworkProcess(ConsoleEvent e)
{
if (e.Name == "AutoSave")
{
Game.Save("autosave", "Auto-save");
}
}
}