Add cleanup function
This commit is contained in:
parent
08ca559ade
commit
4dd809ba03
1 changed files with 7 additions and 0 deletions
7
bc.lua
7
bc.lua
|
|
@ -138,6 +138,8 @@ function bc:init(my_address, local_nouns, local_verbs)
|
||||||
end
|
end
|
||||||
-- Change this for deployment VVV
|
-- Change this for deployment VVV
|
||||||
o.modem = modem:init(my_address, modem_listener)
|
o.modem = modem:init(my_address, modem_listener)
|
||||||
|
-- Save listener function for deinit
|
||||||
|
o.modem_cb = modem_listener
|
||||||
-- Init local stuff
|
-- Init local stuff
|
||||||
o.local_verbs = local_verbs or {}
|
o.local_verbs = local_verbs or {}
|
||||||
o.local_nouns = local_nouns or {}
|
o.local_nouns = local_nouns or {}
|
||||||
|
|
@ -268,4 +270,9 @@ function bc:listen_cancel(n, id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Deinit
|
||||||
|
function bc:cleanup()
|
||||||
|
event.ignore("modem_message", self.modem_cb)
|
||||||
|
end
|
||||||
|
|
||||||
return bc
|
return bc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue