Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- minimodule.lua
- -- set up table to hold "module" bits
- local dsign = {}
- dsign.init = function()
- -- set up default data structures and values
- -- this could actually just be created on the fly
- -- but having an init function helps to document
- dsign.monitors = {}
- dsign.signCount = 0
- dsign.signs = {}
- end
- dsign.addMonitors = function(monitorTable)
- -- Add monitors, we can take an "array" of monitor names,
- -- or a single string
- -- these will be added to our "array" of monitors in the order
- -- they are added
- -- this exceprt only adds the name, but it's here where you could
- -- generate all info for a monitor (reference, bounds, etc)
- if type(monitorTable)=="string" then
- local singleMonitor = monitorTable
- monitorTable = { singleMonitor }
- end
- for m, monitorName in ipairs(monitorTable) do
- local monitorDetails = {}
- monitorDetails.name = monitorName
- -- you can add other monitor attributes to the table above
- -- store all the attributes in the monitors array
- table.insert(dsign.monitors,monitorDetails)
- end
- end
- dsign.showMonitors = function()
- -- this example function shows how to "walk" the monitors
- -- and access their attributes
- for i = 1, table.getn(dsign.monitors) do
- print(i,dsign.monitors[i].name)
- end
- end
- -- "array" of monitor names
- local monitors = { "top", "left", "monitor_0" }
- -- Here we set up our "module"
- dsign.init()
- -- add the monitors from the array
- dsign.addMonitors(monitors)
- -- show we can also add a string
- dsign.addMonitors("oneMore")
- -- function to demonstrate how to use this info
- dsign.showMonitors()
Advertisement
Add Comment
Please, Sign In to add comment