Skip to content

help with modules #203

Answered by rgieseke
LollipopFt asked this question in Q&A
Discussion options

You must be logged in to vote

I think the following should work:

lineguide.lua

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

init.lua

local lineguide = require("lineguide")
lineguide.guides = {80, 100}

The return M makes the modules variables available when you import it. Since the guides variable is not set when you require the module the edge setting is postponed until the initialization finishes.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by LollipopFt
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #202 on May 22, 2022 13:54.