So i'm wanting to make a idle game. In which you upgrade buildings gain gold blah blah.
However i'm not sure how to go about updating the data while someone isn't online as i've never done any networking or any online development.
What would i need? Where should i start. Can i use a database instead of a dedicated server?
Having data update when app is closed (idle)
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 26
- Joined: Sun Jan 15, 2017 6:46 am
Re: Having data update when app is closed (idle)
Why do you need a server? You can just save the time when the app was closed, then when you open it you check how much time has passed and calculate all the things.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
-
- Prole
- Posts: 26
- Joined: Sun Jan 15, 2017 6:46 am
Re: Having data update when app is closed (idle)
i'm so stupid and your a genius.
So something like:
So something like:
Code: Select all
function saveExitTime()
lasttime = os.time()
end
function comparetime()
os.difftime(os.time, lasttime)
end
function love.load()
comparetime()
end
Re: Having data update when app is closed (idle)
Just a simple subtraction could do:
EDIT: how neat, phpBB automatically closes code tags if one forgets
Code: Select all
function love.quit()
local f = love.filesystem.newFile("lastTime", "w")
f:write(os.time())
f:close()
end
function love.load()
local f = love.filesystem.newFile("lastTime", "r")
if f then
local lastTime = f:read() -- was f:read("*a"), fixed now
diffTime = os.time() - lastTime
else
diffTime = 0
end
end
Last edited by Nixola on Wed Jun 07, 2017 7:04 pm, edited 1 time in total.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
-
- Prole
- Posts: 26
- Joined: Sun Jan 15, 2017 6:46 am
Re: Having data update when app is closed (idle)
What does the
Do i get an error saying number expected got string
Code: Select all
f:read("*a)
Re: Having data update when app is closed (idle)
That should just be f:read(). I got confused with Lua files, that's a LÖVE file.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Who is online
Users browsing this forum: Google [Bot] and 5 guests