Created
November 16, 2021 15:51
-
-
Save AGulev/d465e93788d8d77a4ec02e7ff7287c12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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