GE Lua Documentation

Press F to search!

getModForFilename

Definition


-- @/lua/ge/extensions/core/modmanager.lua:1318
local function getModForFilename(filename_virtual)
  local realPath = FS:getFileRealPath(filename_virtual)
  if string.startswith(realPath, gamePath) then
    -- no mods allowed in game path
    return
  end
  if string.startswith(realPath, userPath) then
    local modPath = realPath:sub(string.len(userPath))
    modPath = modPath:gsub("\\", "/")
    local zipPos = modPath:find('.zip')
    if zipPos then
      modPath = modPath:sub(1, zipPos + 3)
    else
      -- not a zip, thus not a mod. unpacked mods not supported right now
      return
    end

    for modname, mod in pairs(mods) do
      if mod.fullpath == modPath then
        return modname, mod
      end
    end
  end
end

Callers

@/lua/common/jbeam/io.lua
        -- enrich the part with modName and ID
        local modName, modInfo = modManager.getModForFilename(filename)
        if modName then