2022-07-03 12:43:10 -04:00
|
|
|
if (game:issingleplayer() or not Engine.InFrontend()) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2022-07-01 03:22:54 -04:00
|
|
|
custom_depot = {
|
|
|
|
collection_details_menu = nil,
|
|
|
|
data = {
|
|
|
|
currencies = {
|
2022-07-03 12:26:15 -04:00
|
|
|
["1"] = 0, -- LaunchCredits
|
|
|
|
["2"] = 0, -- Credits
|
|
|
|
["3"] = 0, -- Parts
|
|
|
|
["4"] = 0, -- CoDPoints
|
|
|
|
["5"] = 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-03 12:26:15 -04:00
|
|
|
directory_path = "h1-mod",
|
2022-07-01 03:22:54 -04:00
|
|
|
file_name = "depot_save.json",
|
|
|
|
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()
|
|
|
|
io.writefile(custom_depot.file_path, json.encode(custom_depot.data, {
|
|
|
|
indent = true
|
|
|
|
}), false)
|
|
|
|
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
|
|
|
|
|
|
|
|
custom_depot.functions["add_currency"] = function(currency_type, amount)
|
2022-07-03 12:43:10 -04:00
|
|
|
custom_depot.data.currencies[tostring(currency_type)] = custom_depot.data.currencies[tostring(currency_type)] +
|
|
|
|
amount
|
2022-07-01 03:22:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["remove_currency"] = function(currency_type, amount)
|
2022-07-03 12:43:10 -04:00
|
|
|
custom_depot.data.currencies[tostring(currency_type)] = custom_depot.data.currencies[tostring(currency_type)] -
|
|
|
|
amount
|
2022-07-01 03:22:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
custom_depot.functions["get_currency"] = function(currency_type)
|
2022-07-03 12:26:15 -04:00
|
|
|
if not currency_type or not custom_depot.data.currencies[tostring(currency_type)] then
|
2022-07-01 03:22:54 -04:00
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
2022-07-03 12:26:15 -04:00
|
|
|
return custom_depot.data.currencies[tostring(currency_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
|
|
|
|
|
|
|
if (Engine.InFrontend()) then
|
|
|
|
require("mod_eula")
|
|
|
|
require("depot_override")
|
|
|
|
end
|
|
|
|
|
|
|
|
if (Engine.InFrontend() == false) then
|
|
|
|
require("scoreboard_override")
|
|
|
|
end
|