milo: peripheral improvements
This commit is contained in:
@@ -24,6 +24,7 @@ local fs = _G.fs
|
|||||||
local multishell = _ENV.multishell
|
local multishell = _ENV.multishell
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
local shell = _ENV.shell
|
local shell = _ENV.shell
|
||||||
|
local turtle = _G.turtle
|
||||||
|
|
||||||
if multishell then
|
if multishell then
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Milo')
|
multishell.setTitle(multishell.getCurrent(), 'Milo')
|
||||||
@@ -71,11 +72,15 @@ if not modem.getNameLocal() then
|
|||||||
Syntax('Wired modem is not active')
|
Syntax('Wired modem is not active')
|
||||||
end
|
end
|
||||||
|
|
||||||
local introspection = Peripheral.get('plethora:introspection') or
|
local introspection = device['plethora:introspection'] or
|
||||||
|
turtle.equip('left', 'plethora:module:0') and device['plethora:introspection'] or
|
||||||
Syntax('Introspection module missing')
|
Syntax('Introspection module missing')
|
||||||
|
|
||||||
if not device.workbench then
|
if not device.workbench then
|
||||||
Syntax('Workbench missing')
|
turtle.equip('right', 'minecraft:crafting_table:0')
|
||||||
|
if not device.workbench then
|
||||||
|
Syntax('Workbench missing')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local context = {
|
local context = {
|
||||||
|
|||||||
@@ -122,15 +122,33 @@ local function client(socket)
|
|||||||
_G._debug('REMOTE: disconnected from ' .. socket.dhost)
|
_G._debug('REMOTE: disconnected from ' .. socket.dhost)
|
||||||
end
|
end
|
||||||
|
|
||||||
if device.wireless_modem then
|
local handler
|
||||||
Event.addRoutine(function()
|
|
||||||
_G._debug('REMOTE: listening on port 4242')
|
local function listen()
|
||||||
while true do
|
if device.wireless_modem then
|
||||||
local socket = Socket.server(4242)
|
handler = Event.addRoutine(function()
|
||||||
Event.addRoutine(function()
|
_G._debug('REMOTE: listening on port 4242')
|
||||||
client(socket)
|
while true do
|
||||||
socket:close()
|
local socket = Socket.server(4242)
|
||||||
end)
|
Event.addRoutine(function()
|
||||||
end
|
client(socket)
|
||||||
end)
|
socket:close()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Event.on({ 'device_attach', 'device_detach' }, function(_, name)
|
||||||
|
if name == 'wireless_modem' then
|
||||||
|
if handler then
|
||||||
|
handler:terminate()
|
||||||
|
handler = nil
|
||||||
|
_debug('REMOTE: wireless modem disconnected')
|
||||||
|
else
|
||||||
|
listen()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
listen()
|
||||||
|
|||||||
Reference in New Issue
Block a user