Open andytudhope opened 7 months ago
Sure you can just define a function and it will load into the Global Scope
function MyGreeting(name)
return "Hello " .. name
end
But you may want to organize better, Lua has modules which are files with a simple scope
You can create a module locally like
mod.lua
local mod = { _version = "0.1" }
function mod.greeting(name)
return "Hello " .. name
end
return mod
Then in your load file main.lua
local mod = require('.mod')
function hello()
mod.greeting('rakis')
end
You can also implement metatables - here is an example
https://github.com/permaweb/aos/blob/main/blueprints/credUtils.lua
As described in the TODO here, this approach does not load anything more complex than
Handlers.utils.whatever
.How do I load actual functions? It may just be a case of structuring the message to the process slightly differently? Or it may require deeper changes to the lua script...