There are a number of ways to save Mudlet variables, but by far the easiest method is via script and saving your variables to tables.
When you create your variables in scripts prepend them with a namespace or identifier (which is just a table).
So your hitpoints variable will become myVars.hitpoints. Now anytime myVars is saved, all variable underneath are saved too, which then of course can be reloaded at next startup.
Put this script up the top of your Script Editor so your variables are loaded first thing into Mudlet ( (scripts are loaded in order).
-- table to put your variables (i.e., namespace or identifier)
myVars = myVars or {}
-- save file is stored in your profile
local file = getMudletHomeDir().."/myVars.lua"
-- check if the variables file exists and load it
if io.exists(file) then
table.load(file, myVars)
else
cecho(f"\n<red>Variables file '{file}' NOT loaded!<r>\n")
end
-- automatic file save on disconnection
registerNamedEventHandler("save variables", "save variables on shutdown", "sysDisconnectionEvent", function()
table.save(file, myVars)
end)