A few questions:
Is there really a file called M.lua in the main project directory? Or is this just example code?
Also, what is ‘rectOptions’? If it’s a table, that won’t work - the parameters of newRect are not passed inside a table. You’d have to pass rectOptions[1], rectOptions[2] or rectOptions.width, rectOptions.height etc. depending on how the table is structured.
[lua]
– module.lua
local m = {}
m.path = {type = “image”, filename = “path/to/file.png”}
return m
[/lua]
[lua]
local myModuleHandle = require(“path/to/module”) – I must be called module.lua and in the folder path/to/
local image = display.newRect(100, 100, 100, 100)
image.fill = myModuleHandle.path
[/lua]
If that still doesn’t work, verify you can create an ordinary display.newImageRect using the same image path.