In my game, user collects coins which can later be spent on different skins and upgrades in the shop. Number of owned coins is saved on the local machine wih this primitive code:
function Increase_money(amount)
local filename = sys.get_save_file("shep", "money") -- path too save file
local data = sys.load(filename) -- loads data
-- increase
if data.money == nil then
data.money = 0
end
data.money = data.money + amount
-- save money
sys.save(filename, { money = data.money })
end
function Money()
--returns current money
local filename = sys.get_save_file("shep", "money")
local data = sys.load(filename) -- loads data
-- check if data.money exists
if data.money == nil then
data.money = 0
sys.save(filename, { money = 0 })
end
return data.money
end
(TLDR: amount of owned coins is saved directly via sys.get_save_file(). =
Apart from collecting coins, user can also buy them via in-app purchases. Because of that, it is in my interest that the in-game currency mechanism would be safe and free of easy-to-find exploits.
I guess this is not the case right now? Data, saved on local machine via sys.get_save_file()
can probably be easily accesed and changed from outside the game.
What are some workarounds that fix my problem?
- I could implement another in-game currency, which is not saved on local machine, but rather just on google servers, and can only be collected via in-app purchases, and than make some of the upgrades available to buy just with this new currency. But I would like to avoid this solution, because I still want every part of the game to be (theoretically) accessible without paying.
- I could save the number of owned coins just on some servers, but I want to avoid being reliable to internet services. I want my game (outside of iap) to be fully functionable without internet access.
Is there a way to only have one in-game currency and store the number of coins safely on my machine? My guess is, I could encrypt the number somehow before saving, but I do not know which tools are suitable for that.