I have a tiles.lua:
local tiles = {} function tiles.Create() tileTest = Tile.Add("Test Tile", "tiles/test_tile.png", "test_tile") World.AddTile(tileTest, 0, 0) World.AddTile(tileTest, 16, 0) World.AddTile(tileTest, 32, 0) end return tiles
and a main.lua:
require "src.tiles" function init() tiles.Create() end
My game runs the init function of main.lua on game start, and the function tiles.Create() in tiles.lua works perfectly fine when placed inside function init() in main.lua.
(It should be noted that tiles.lua is located in src/tiles.lua in relation to main.lua. I've also tried `require "tiles"` with tiles.lua in the same directory as main.lua but that doesn't work either)
EDIT: Turns out require does not want the path relative to your current path, but from the root datafiles path. Changing this to
local tiles = require "mods.base.src.tiles"
when the folder structure is
datafiles |mods ||base |||src ||||tiles.lua |||main.lua
works perfectly fine. Leaving this post up in case others encounter a similar issue :)