Or you write it down in an extra file. Then you can carry a lot more vars. I did it here with health but you can do it with any vars you want
-- Created by Corno_1
local vars_imported = 0
local vars_exported = 0
local startHealth = 100
local startLives = 3
function export_values_init(e)
end
function export_values_main(e)
if g_PlayerLives < 1 then
writeLiveHealthInFile(startLives,startHealth)
end
if vars_imported == 0 then
local temp = {}
local StartVars = io.open("scriptbank/Corno_1/LevelValuesImExport/values.saves", "r")
local i = 1
while i <= 2 do
temp[i] = StartVars:read("*line")
local indexOfChar = string.find(temp[i],"=")
if indexOfChar ~= nil then
temp[i] = string.sub(temp[i],indexOfChar+1)
i=i+1
end
end
StartVars:close()
SetPlayerLives(e,temp[1])
SetPlayerHealth(temp[2])
vars_imported = 1
end
if g_Entity[e]['plrinzone']==1 then
if vars_exported == 0 then
writeLiveHealthInFile(g_PlayerLives,g_PlayerHealth)
vars_exported = 1
end
end
end
function writeLiveHealthInFile(PlayerLives,PlayerHealth)
local temp = {}
local StartVars = io.open("scriptbank/Corno_1/LevelValuesImExport/values.saves", "w")
StartVars:write("Lifes=" .. PlayerLives .."\n")
StartVars:write("Health=" .. PlayerHealth)
StartVars:close()
end
My dream is to develope games, which makes fun when I create it and fun when other people play it.