[Lua] Using modules as table files

Section's for general approaches on hacking various options in games. No online-related discussions/posts OR warez!
Post Reply
TimFun13
Expert Cheater
Expert Cheater
Posts: 1353
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 7

[Lua] Using modules as table files

Post by TimFun13 »

[Link]



In this video I go over using Lua modules as table files.



Code: Select all

-- Loaded in table lua script
-- Table File Package Loader
 function tableFilePackageLoader(name, modPath)
 local tableFile = findTableFile(modPath)
 if tableFile then
 local stream = tableFile.getData()
 if stream then
 local fileStr = readStringLocal(stream.memory, stream.size)
 if fileStr then
 local status, ret = pcall(load, fileStr, modPath)
 if not status then error(ret, 2) end
 return ret(name, modPath)
 end
 end
 end
 error(string.format('Error loading table module: %s : %s', name, modPath), 2)
 end
 function tableFilePackageSearcher(name)
 local err = ''
 local mod_paths = { name..'.lua', name..'.init.lua' }
 local tableFile, modPath
 for i, path in ipairs(mod_paths) do
 tableFile = findTableFile(path)
 if tableFile then
 modPath = path
 break
 else
 err = err..string.format("\n\tno table file '%s'", path)
 end
 end
 if tableFile and modPath then
 return tableFilePackageLoader, modPath
 end
 return err
 end
 if not TABLE_LUA_PACKAGE_SEARCHER_LOADED then
 if RELEASE_MODE then
 table.insert(package.searchers, 2, tableFilePackageSearcher)
 else
 table.insert(package.searchers, tableFilePackageSearcher)
 end
 TABLE_LUA_PACKAGE_SEARCHER_LOADED = true 
 end
 ---- Bypass require for better formated outputs
 if not REQUIRE_BYPASS_LOADED then
 local _require = require
 function require(name)
 if REREQUIRE or RerequireList and RerequireList[name] then
 package.loaded[name] = false
 end
 local status, ret = pcall(_require, name)
 if status then
 return ret
 else
 local err = ret:gsub('\n', '\r\n'):gsub('.dllC:\\', ".dll'\r\n\tno file 'C:\\")
 error(err, 2)
 end
 end
 REQUIRE_BYPASS_LOADED = true
 end
Table File Packer Tool

Post Reply

Who is online

Users browsing this forum: No registered users