2022-07-03 16:04:25 -04:00
|
|
|
if game:issingleplayer() then
|
2022-07-03 12:43:10 -04:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2022-07-04 19:47:08 -04:00
|
|
|
-- from mpdepotbase.lua, global definition isn't working
|
|
|
|
InventoryCurrencyType = {
|
|
|
|
LaunchCredits = 1,
|
|
|
|
Credits = 2,
|
|
|
|
Parts = 3,
|
|
|
|
CoDPoints = 4,
|
|
|
|
Bonus = 5,
|
|
|
|
Max = 6
|
|
|
|
}
|
|
|
|
|
2022-07-07 03:50:54 -04:00
|
|
|
ItemRarity = {
|
|
|
|
Common = 0,
|
|
|
|
Rare = 1,
|
|
|
|
Legendary = 2,
|
|
|
|
Epic = 3
|
|
|
|
}
|
|
|
|
|
2022-07-01 03:22:54 -04:00
|
|
|
custom_depot = {
|
|
|
|
collection_details_menu = nil,
|
|
|
|
data = {
|
|
|
|
currencies = {
|
2022-07-03 15:52:47 -04:00
|
|
|
launchCredits = 0, -- LaunchCredits
|
|
|
|
credits = 0, -- Credits
|
|
|
|
parts = 0, -- Parts
|
|
|
|
codPoints = 0, -- CoDPoints
|
|
|
|
bonus = 0 -- Bonus
|
2022-07-01 03:22:54 -04:00
|
|
|
},
|
|
|
|
items = {},
|
2022-07-02 18:56:21 -04:00
|
|
|
reward_splashes = {},
|
|
|
|
has_accepted_mod_eula = false,
|
2022-07-03 12:43:10 -04:00
|
|
|
has_seen_mod_eula = false
|
2022-07-01 03:22:54 -04:00
|
|
|
},
|
2022-07-08 11:12:02 -04:00
|
|
|
directory_path = "players2/user",
|
|
|
|
file_name = "depot.json",
|
2022-07-01 03:22:54 -04:00
|
|
|
file_path = nil,
|
2022-07-03 12:26:15 -04:00
|
|
|
functions = {}
|
2022-07-01 03:22:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
custom_depot.file_path = string.format("%s/%s", custom_depot.directory_path, custom_depot.file_name)
|
|
|
|
|
|
|
|
custom_depot.get_function = function(function_name)
|
|
|
|
if not function_name or not custom_depot.functions[function_name] then
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
return custom_depot.functions[function_name]
|
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["save_depot_data"] = function()
|
2022-07-03 15:52:47 -04:00
|
|
|
io.writefile(custom_depot.file_path, json.encode(custom_depot.data), false)
|
2022-07-01 03:22:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["load_depot_data"] = function()
|
|
|
|
if not io.directoryexists(custom_depot.directory_path) then
|
2022-07-03 12:30:12 -04:00
|
|
|
io.createdirectory(custom_depot.directory_path)
|
2022-07-01 03:22:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
if not io.fileexists(custom_depot.file_path) then
|
|
|
|
custom_depot.get_function("save_depot_data")()
|
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.data = json.decode(io.readfile(custom_depot.file_path))
|
|
|
|
end
|
|
|
|
|
2022-07-03 15:52:47 -04:00
|
|
|
local function convert_currency_to_string(type)
|
|
|
|
if type == InventoryCurrencyType.LaunchCredits then
|
|
|
|
return "launchCredits"
|
|
|
|
elseif type == InventoryCurrencyType.Credits then
|
|
|
|
return "credits"
|
|
|
|
elseif type == InventoryCurrencyType.Parts then
|
|
|
|
return "parts"
|
|
|
|
elseif type == InventoryCurrencyType.CoDPoints then
|
|
|
|
return "codPoints"
|
|
|
|
elseif type == InventoryCurrencyType.Bonus then
|
|
|
|
return "bonus"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-07-01 03:22:54 -04:00
|
|
|
custom_depot.functions["add_currency"] = function(currency_type, amount)
|
2022-07-03 15:52:47 -04:00
|
|
|
local type = convert_currency_to_string(currency_type)
|
|
|
|
custom_depot.data.currencies[type] = custom_depot.data.currencies[type] + amount
|
2022-07-01 03:22:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["remove_currency"] = function(currency_type, amount)
|
2022-07-03 15:52:47 -04:00
|
|
|
local type = convert_currency_to_string(currency_type)
|
|
|
|
custom_depot.data.currencies[type] = custom_depot.data.currencies[type] - amount
|
2022-07-01 03:22:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["get_currency"] = function(currency_type)
|
2022-07-03 16:04:25 -04:00
|
|
|
local type = convert_currency_to_string(currency_type)
|
|
|
|
|
|
|
|
if not currency_type or not custom_depot.data.currencies[type] then
|
2022-07-01 03:22:54 -04:00
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
2022-07-03 16:04:25 -04:00
|
|
|
return custom_depot.data.currencies[type]
|
2022-07-01 03:22:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["add_item"] = function(item, value)
|
|
|
|
custom_depot.data.items[item] = value
|
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["has_item"] = function(item)
|
|
|
|
return custom_depot.data.items[item] ~= nil
|
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["add_reward_splash"] = function(item, value)
|
|
|
|
custom_depot.data.reward_splashes[item] = value
|
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["has_reward_splash"] = function(item)
|
|
|
|
return custom_depot.data.reward_splashes[item] ~= nil
|
|
|
|
end
|
|
|
|
|
2022-07-02 18:56:21 -04:00
|
|
|
custom_depot.functions["has_accepted_mod_eula"] = function()
|
|
|
|
return custom_depot.data.has_accepted_mod_eula
|
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["set_has_accepted_mod_eula"] = function(value)
|
|
|
|
custom_depot.data.has_accepted_mod_eula = value
|
|
|
|
custom_depot.get_function("save_depot_data")()
|
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["has_seen_mod_eula"] = function()
|
|
|
|
return custom_depot.data.has_seen_mod_eula
|
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["set_has_seen_mod_eula"] = function(value)
|
|
|
|
custom_depot.data.has_seen_mod_eula = value
|
|
|
|
custom_depot.get_function("save_depot_data")()
|
|
|
|
end
|
|
|
|
|
2022-07-01 03:22:54 -04:00
|
|
|
custom_depot.get_function("load_depot_data")()
|
2022-07-03 12:43:10 -04:00
|
|
|
|
2022-07-03 16:04:25 -04:00
|
|
|
if Engine.InFrontend() then
|
2022-07-03 12:43:10 -04:00
|
|
|
require("mod_eula")
|
|
|
|
require("depot_override")
|
|
|
|
end
|
|
|
|
|
2022-07-03 16:04:25 -04:00
|
|
|
if not Engine.InFrontend() then
|
2022-07-03 12:43:10 -04:00
|
|
|
require("scoreboard_override")
|
|
|
|
end
|