Skip to content

Commit

Permalink
add gamemode path finding
Browse files Browse the repository at this point in the history
  • Loading branch information
EvaisaDev committed Jun 30, 2024
1 parent 10691f7 commit 4b66dab
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
69 changes: 69 additions & 0 deletions evaisa.mp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,75 @@ function GuiOptionsList(gui)
return options
end

local gamemode_path = nil

function GetGamemodeFilePath()

if(gamemode_path)then
return gamemode_path
end

print("Fixing falsely enabled gamemodes")

local save_folder = os.getenv('APPDATA'):gsub("\\Roaming", "") ..
"\\LocalLow\\Nolla_Games_Noita\\save00\\mod_config.xml"

local things = {}

for k, v in ipairs(ModGetActiveModIDs()) do
things[v] = true
end

local file_path = nil

local file, err = io.open(save_folder, 'rb')
if file then

print("Found mod_config.xml")

local content = file:read("*all")

local parsedModData = nxml.parse(content)
for elem in parsedModData:each_child() do
if (elem.name == "Mod") then
local modID = elem.attr.name
local steamID = elem.attr.workshop_item_id

local infoFile = "mods/" .. modID .. "/mod.xml"
if (steamID ~= "0") then
infoFile = "../../workshop/content/881100/" .. steamID .. "/mod.xml"
end

local file2, err = io.open(infoFile, 'rb')
if file2 then
local content2 = file2:read("*all")
local parsedModInfo = nxml.parse(content2)

local is_game_mode = parsedModInfo.attr.is_game_mode == "1"

if (ModIsEnabled(modID) and is_game_mode) then
print("Found enabled gamemode: " .. modID)
if steamID == "0" then
file_path = "mods/" .. modID
else
file_path = "../../workshop/content/881100/" .. steamID
end
break
end
end

end
end
file:close()


end

gamemode_path = file_path

return file_path
end


if(trailer_mode)then
ModMagicNumbersFileAdd("mods/evaisa.mp/magic_numbers_trailer.xml")
Expand Down
2 changes: 1 addition & 1 deletion evaisa.mp/version.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MP_VERSION = 368
MP_VERSION = 370
MP_PRESET_VERSION = 2

0 comments on commit 4b66dab

Please sign in to comment.