Steamopollys / Steamodded

A Balatro ModLoader
GNU General Public License v3.0
199 stars 43 forks source link

feat: SMODS.load_file #186

Closed WilsontheWolf closed 1 month ago

WilsontheWolf commented 1 month ago

Add's a new method, SMODS.load_file(path, id). This method take's in a path, relative to the mod's main directory, and optinally the mod id (will use SMODS.current_mod if not. Just got thinking should I require the mod object instead of the id?). It then reads the file and loads it. Return type is the same as love.filesystem.load and loadfile.

Example: Main.lua

--- STEAMODDED HEADER
--- MOD_NAME: Load Test
--- MOD_ID: LoadTest
--- MOD_AUTHOR: [WilsontheWolf]
--- MOD_DESCRIPTION: Testing for new api
----------------------------------------------
------------MOD CODE -------------------------
local mod = SMODS.current_mod;

assert(SMODS.load_file("Loaded.lua"))()
----------------------------------------------
------------MOD CODE END----------------------

Loaded.lua

print("Hi mom")

-- error("Test") -- Uncomment me to see that my filename is properly shown in the crash log
english5040 commented 1 month ago

Merged