added toggle
This commit is contained in:
parent
2c7d119400
commit
d758bb9e55
@ -51,26 +51,37 @@ function recv()
|
||||
term.setCursorPos(1, 1)
|
||||
term.setTextColor(colors.white)
|
||||
term.setBackgroundColor(colors.black)
|
||||
write('Press "R" to toggle the rainbows.\n')
|
||||
-- xPos, yPos = term.getCursorPos()
|
||||
-- term.setCursorPos(1,(yPos + 1))
|
||||
write('Press "T" to toggle the rainbows.\n')
|
||||
term.write('Rainbows state: ')
|
||||
if redstone_toggle_state == true then
|
||||
term.setBackgroundColor(colors.green)
|
||||
write('On')
|
||||
write('On\n')
|
||||
elseif redstone_toggle_state == false then
|
||||
term.setBackgroundColor(colors.red)
|
||||
write('Off')
|
||||
write('Off\n')
|
||||
elseif redstone_toggle_state == nil then
|
||||
term.setBackgroundColor(colors.purple)
|
||||
write('Unknown')
|
||||
write('Unknown\n')
|
||||
end
|
||||
print()
|
||||
term.setBackgroundColor(colors.black)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function key_watcher()
|
||||
while true do
|
||||
local event, param = os.pullEvent("key")
|
||||
if event == "key" then
|
||||
-- print("Got key: " .. param)
|
||||
if param == keys.backspace then
|
||||
break
|
||||
elseif param == keys.t then
|
||||
rednet.send(redstone_toggle_id, 'toggle')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local sides = peripheral.getNames()
|
||||
for i = 1, #sides do
|
||||
if peripheral.getType(sides[i]) == "modem" then
|
||||
@ -82,5 +93,5 @@ end
|
||||
rednet.open(modemSide)
|
||||
rednet.host("rmm", "master")
|
||||
|
||||
parallel.waitForAny(poll, recv)
|
||||
parallel.waitForAny(poll, recv, key_watcher)
|
||||
rednet.close(modemSide)
|
||||
|
Loading…
x
Reference in New Issue
Block a user