JoselleAstrid/ram-watch-cheat-engine

Make filepaths explicit for core framework modules

Opened this issue · 0 comments

Most Lua modules in the framework are loaded with require without specifying a particular folder. This means the modules can be found within RWCEMainDirectory, RWCEExtraDirectories, or even the cheat table directory (as pointed out by Fog of TASvideos).

This flexibility is useful for user-defined game modules and layout modules. But for core framework modules like dolphin.lua, utils.lua, etc. there's no disadvantage to specifying an explicit filepath to load, such as RWCEMainDirectory .. '/dolphin.lua'. More explicit filepaths means fewer confusing file conflicts.

Currently, the only explicit module path is the one for loader.lua, specified in the tutorial's top level cheat table script:

local loaderFile, errorMessage = loadfile(RWCEMainDirectory .. '/loader.lua')
if errorMessage then error(errorMessage) end
loaderFile()

So one approach is to replace all usages of require with this loadfile pattern. I'm not sure if it's the best way though. Might be worth re-reading the Lua docs to see if there's other approaches.