testing
This commit is contained in:
		
							parent
							
								
									71831d464d
								
							
						
					
					
						commit
						2eb429d0ce
					
				@ -1,6 +1,5 @@
 | 
				
			|||||||
redstone_toggle_id = 48
 | 
					redstone_toggle_id = 48
 | 
				
			||||||
de_store_mon_id = nil
 | 
					de_store_mon_id = nil
 | 
				
			||||||
redstone_toggle_state = nil
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
function dump(o)
 | 
					function dump(o)
 | 
				
			||||||
    if o == nil then
 | 
					    if o == nil then
 | 
				
			||||||
@ -32,42 +31,43 @@ function poll()
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function recv()
 | 
					function recv()
 | 
				
			||||||
 | 
					    local redstone_toggle_state = nil
 | 
				
			||||||
 | 
					    local updated = false
 | 
				
			||||||
    while true do
 | 
					    while true do
 | 
				
			||||||
        local id, data = rednet.receive()
 | 
					        local id, data = rednet.receive()
 | 
				
			||||||
        if id == redstone_toggle_id then
 | 
					        if id == redstone_toggle_id then
 | 
				
			||||||
            if type(data) == 'table' then
 | 
					            if type(data) == 'table' then
 | 
				
			||||||
                if data[1] == 'output_state' then
 | 
					                if data[1] == 'output_state' then
 | 
				
			||||||
                    redstone_toggle_state = data[2]
 | 
					                    redstone_toggle_state = data[2]
 | 
				
			||||||
 | 
					                    updated = true
 | 
				
			||||||
                end
 | 
					                end
 | 
				
			||||||
            end
 | 
					            end
 | 
				
			||||||
        elseif id == de_store_mon_id then
 | 
					        elseif id == de_store_mon_id then
 | 
				
			||||||
            -- todo
 | 
					            -- todo
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
function draw_screen()
 | 
					        if updated == true then
 | 
				
			||||||
    while true do
 | 
					            print(tostring(redstone_toggle_state))
 | 
				
			||||||
        print(tostring(redstone_toggle_state))
 | 
					            -- term.clear()
 | 
				
			||||||
        -- term.clear()
 | 
					            -- term.setCursorPos(0, 0)
 | 
				
			||||||
        -- term.setCursorPos(0, 0)
 | 
					            -- term.setTextColor(colors.white)
 | 
				
			||||||
        -- term.setTextColor(colors.white)
 | 
					            -- term.setBackgroundColor(colors.black)
 | 
				
			||||||
        -- term.setBackgroundColor(colors.black)
 | 
					            -- print('Press "R" to toggle the rainbows')
 | 
				
			||||||
        -- print('Press "R" to toggle the rainbows')
 | 
					            -- term.write('Rainbows state: ')
 | 
				
			||||||
        -- term.write('Rainbows state: ')
 | 
					            -- if redstone_toggle_state == true then
 | 
				
			||||||
        -- if redstone_toggle_state == true then
 | 
					            --     term.setBackgroundColor(colors.green)
 | 
				
			||||||
        --     term.setBackgroundColor(colors.green)
 | 
					            --     term.write('On')
 | 
				
			||||||
        --     term.write('On')
 | 
					            -- elseif redstone_toggle_state == false then
 | 
				
			||||||
        -- elseif redstone_toggle_state == false then
 | 
					            --     term.setBackgroundColor(colors.red)
 | 
				
			||||||
        --     term.setBackgroundColor(colors.red)
 | 
					            --     term.write('Off')
 | 
				
			||||||
        --     term.write('Off')
 | 
					            -- elseif redstone_toggle_state == nil then
 | 
				
			||||||
        -- elseif redstone_toggle_state == nil then
 | 
					            --     term.setBackgroundColor(colors.purple)
 | 
				
			||||||
        --     term.setBackgroundColor(colors.purple)
 | 
					            --     term.write('Unknown')
 | 
				
			||||||
        --     term.write('Unknown')
 | 
					            -- end
 | 
				
			||||||
        -- end
 | 
					            -- print()
 | 
				
			||||||
        -- print()
 | 
					            -- term.setBackgroundColor(colors.black)
 | 
				
			||||||
        -- term.setBackgroundColor(colors.black)
 | 
					            sleep(1)
 | 
				
			||||||
        sleep(1)
 | 
					        end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -82,5 +82,5 @@ end
 | 
				
			|||||||
rednet.open(modemSide)
 | 
					rednet.open(modemSide)
 | 
				
			||||||
rednet.host("rmm", "master")
 | 
					rednet.host("rmm", "master")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
parallel.waitForAny(poll, recv, draw_screen)
 | 
					parallel.waitForAny(poll, recv)
 | 
				
			||||||
rednet.close(modemSide)
 | 
					rednet.close(modemSide)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user