changed ppm to not wrap under ppm() function

This commit is contained in:
Mikayla Fischler 2022-03-10 14:12:07 -05:00
parent ea84563bb4
commit a0b2c1f3e2

View File

@ -4,7 +4,6 @@
-- Protected Peripheral Manager
--
function ppm()
local self = {
mounts = {}
}
@ -28,7 +27,7 @@ function ppm()
end
-- mount all available peripherals (clears mounts first)
local mount_all = function ()
function mount_all()
local ifaces = peripheral.getNames()
self.mounts = {}
@ -41,7 +40,7 @@ function ppm()
end
-- mount a particular device
local mount = function (name)
function mount(name)
local ifaces = peripheral.getNames()
local pm_dev = nil
@ -62,7 +61,7 @@ function ppm()
end
-- handle peripheral_detach event
local unmount_handler = function (iface)
function unmount_handler(iface)
-- what got disconnected?
local lost_dev = self.mounts[iface]
local type = lost_dev.type
@ -73,22 +72,22 @@ function ppm()
end
-- list all available peripherals
local list_avail = function ()
function list_avail()
return peripheral.getNames()
end
-- list mounted peripherals
local list_mounts = function ()
function list_mounts()
return self.mounts
end
-- get a mounted peripheral by side/interface
local get_periph = function (iface)
function get_periph(iface)
return self.mounts[iface].device
end
-- get a mounted peripheral by type
local get_device = function (name)
function get_device(name)
local device = nil
for side, data in pairs(self.mounts) do
@ -102,7 +101,7 @@ function ppm()
end
-- list all connected monitors
local list_monitors = function ()
function list_monitors()
local monitors = {}
for side, data in pairs(self.mounts) do
@ -113,15 +112,3 @@ function ppm()
return monitors
end
return {
mount_all = mount_all,
mount = mount,
umount = unmount_handler,
list_avail = list_avail,
list_mounts = list_mounts,
get_periph = get_periph,
get_device = get_device,
list_monitors = list_monitors
}
end