removed concept of a master
This commit is contained in:
parent
132e7e4746
commit
9bd6cd94c8
@ -1,3 +1,5 @@
|
||||
local hostname = "pocket_computer" .. os.getComputerID()
|
||||
|
||||
redstone_toggle_id = 50
|
||||
de_store_mon_id = nil
|
||||
|
||||
@ -91,7 +93,7 @@ for i = 1, #sides do
|
||||
end
|
||||
|
||||
rednet.open(modemSide)
|
||||
rednet.host("rmm", "master")
|
||||
rednet.host("rmm", hostname)
|
||||
|
||||
parallel.waitForAny(poll, recv, key_watcher)
|
||||
rednet.close(modemSide)
|
||||
|
@ -27,36 +27,36 @@ function recv()
|
||||
local cmd_fn, err = loadstring(data[2])
|
||||
if not cmd_fn then
|
||||
print("Failed to compile '" .. data[2] .. "': " .. err)
|
||||
rednet.send(master, "Failed to compile '" .. data[2] .. "': " .. err)
|
||||
rednet.send(id, "Failed to compile '" .. data[2] .. "': " .. err)
|
||||
else
|
||||
local success, output = pcall(cmd_fn)
|
||||
if success then
|
||||
if output then
|
||||
print("Command output from '" .. data[2] .. "': " .. dump(output))
|
||||
rednet.send(master, "Command output from '" .. data[2] .. "': " .. dump(output))
|
||||
rednet.send(id, "Command output from '" .. data[2] .. "': " .. dump(output))
|
||||
else
|
||||
print("There is no command output from '" .. data[2] .. "'")
|
||||
rednet.send(master, "There is no command output from '" .. data[2] .. "'")
|
||||
rednet.send(id, "There is no command output from '" .. data[2] .. "'")
|
||||
end
|
||||
else
|
||||
print("Runtime error: " .. output)
|
||||
rednet.send(master, "Runtime error: " .. output)
|
||||
rednet.send(id, "Runtime error: " .. output)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif type(data) == 'string' then
|
||||
if data == 'ping' then
|
||||
print("Pong!")
|
||||
rednet.send(master, "Pong!")
|
||||
rednet.send(id, "Pong!")
|
||||
elseif data == 'toggle' then
|
||||
local output_state = not redstone.getInput("back")
|
||||
redstone.setOutput("back", output_state)
|
||||
print("Toggled output to: " .. tostring(output_state))
|
||||
rednet.send(master, "Toggled output to: " .. tostring(output_state))
|
||||
rednet.send(id, "Toggled output to: " .. tostring(output_state))
|
||||
elseif data == 'get_state' then
|
||||
local output_state = redstone.getInput("back")
|
||||
print("Output state: " .. tostring(output_state))
|
||||
rednet.send(master, {'output_state', output_state})
|
||||
rednet.send(id, {'output_state', output_state})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -72,7 +72,6 @@ function lever_input()
|
||||
local output_state = not redstone.getInput("back")
|
||||
redstone.setOutput("back", output_state)
|
||||
print("Toggled output to: " .. tostring(output_state))
|
||||
rednet.send(master, "Toggled output to: " .. tostring(output_state))
|
||||
end
|
||||
sleep(1)
|
||||
end
|
||||
@ -88,7 +87,6 @@ end
|
||||
|
||||
rednet.open(modemSide)
|
||||
rednet.host("rmm", hostname)
|
||||
master = rednet.lookup("rmm", "master")
|
||||
|
||||
parallel.waitForAny(recv, lever_input)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user