help with modules #203
-
hi, I have this module with filename for _, i in ipairs(_G.guides) do
_G.view:multi_edge_add_line(i, 0x808080)
end
_G.view.edge_mode = view.EDGE_MULTILINE and have this in my _G.guides = {80, 100} to get line guides at the specified columns. however, i see other plugins using something like local M = {}
M.guides = {} and their [module name].guides = {80, 100) and getting values from there. i have tried using that but failed so may i know how this can be achieved since i do not want to use global( |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I think the following should work:
local M = {}
M.guides = {}
events.connect(events.INITIALIZED, function()
for _, i in ipairs(M.guides) do
view:multi_edge_add_line(i, 0x808080)
end
view.edge_mode = view.EDGE_MULTILINE
end)
return M
local lineguide = require("lineguide")
lineguide.guides = {80, 100} The |
Beta Was this translation helpful? Give feedback.
-
i see, thank you! |
Beta Was this translation helpful? Give feedback.
I think the following should work:
lineguide.lua
init.lua
The
return M
makes the modules variables available when you import it. Since theguides
variable is not set when you require the module the edge setting is postponed until the initialization finishes.