Skip to content

Instantly share code, notes, and snippets.

@AGulev
Created Nov 16, 2021
Embed
What would you like to do?
function M.check_keys(callback)
local max_keys = data.BALANCE.CONST.max_key_counts[wallet.max_key_index]
if wallet.keys < max_keys then
local dif = 0
local time_key
if uptime then
time_key = "last_key_use_time_cpu"
dif = uptime.get() - wallet.last_key_use_time_cpu + 1
end
if dif <= 0 then
time_key = "last_key_use_time"
dif = os.time() - wallet.last_key_use_time + 1
end
local regen = data.BALANCE.CONST.key_time_regen
while dif > regen and wallet.keys < max_keys do
dif = dif - regen
wallet[time_key] = wallet[time_key] + regen - 1
wallet.keys = wallet.keys + 1
end
end
save.wallet()
callback()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment