Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Aether

Members
  • Content Count

    12
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Aether

  1. This is the program.

    local component = require("component")
    local sensor = component.motion_sensor
    local sides = require("sides")
    local io = require("io")
    local term = require("term")
    local event = require("event")
    sensor.setSensitivity(0.2)
    local range=1
    ------ Functions -----
    
    function close()
        local rs1 = component.proxy("bebe4c8f-a23e-4e7a-baec-be0124a0b598")
        rs1.setOutput(sides.right,0)
        os.sleep(1)  
      for address in component.list("redstone",true) do
            local rs = component.proxy(address)
            rs.setOutput(sides.top,15)
      end
    end
    
    function open()
      for address in component.list("redstone",true) do
        local rs = component.proxy(address)   
        rs.setOutput(sides.top,0)
       end
       os.sleep(1)  
       local rs1 = component.proxy("bebe4c8f-a23e-4e7a-baec-be0124a0b598")
       rs1.setOutput(sides.right,15)
     end
    
    function openMan()
      open()
      print("Closing it in 8 seconds")
      os.sleep(8)
      close()
    end
    
    function detect()
        print("Detecting...")
      while true do
        local _,_,x,y,z,name=event.pull("motion")  
        if math.abs(x)<=tonumber(range) and math.abs(y)<=tonumber(range) and math.abs(z)<=tonumber(range) then  
          if name == "AetherEus" then
             open()
             print("Detected:",name)
             print("Closing the staircase in 10 seconds")
             os.sleep(10)
             close()
             return false            
          end
        end
      end
    end
    close()
    ---- end ---- 
    ---- Menu ----
    if component.isAvailable("motion_sensor") then
      repeat
        print("Aileen:Program Started. What do I do now?")
        print("1.Open the staircase.\n2.Star detection mode.\n3.Close the staircase.\n4.Close the program.")
    
        local inst=io.read("*n")
      
        if inst==1 then term.clear() print("Aileen: Opening.") openMan() os.sleep(1) detect() end
        if inst==2 then term.clear() print("Aileen: Starting detection mode.") detect() end
        if inst==4 then term.clear() print("Aileen: Closing the program.") term.clear() end
        if inst==3 then term.clear() print("Aileen: Closing the staircase.") close() end
        until inst == 4
      else
      print("Plug in the motion sensor!!!")
    end
    return 0

    It's simple it activates or deactivates a redstone machanism that opens up a path to a staircase. The two things I want to fix or add is  1. A  way to manually cancel the detecting process. 2.Fix that the motion sensor takes to long to detect or I need to jump a lo to make it work. 

    6oUeqbV.jpg

    6y5oaNy.jpgkdz7qFc.jpg

     

  2. This is the code, I only tweaked the colors in the gui.lua but didn't touch anything else. 

    local component = require("component")
    local gpu = component.gpu
    local gui = require("gui")
    local prgName = "Door control"
    local version = "0.1"
    local sides = require("sides")
    local term = require("term")
    local event = require("event")
    local i = 0
    local io = require("io")
    
    
    function toggleRedstone(guiID, id)
      for address in component.list("redstone",true) do
        rs = component.proxy(address)
        rs.setOutput(5,15)
       end
    end
    function untoggleRedstone(guiID, id)
      for address in component.list("redstone",true) do
        rs = component.proxy(address)     
        rs.setOutput(5,0)  
      end
    end
    
    
    function buttonCallback(guiID, id)
      local result = gui.getYesNo("", "Sure?", "")
      if result == true then
        gui.exit()
      end
        gui.displayGui(myGui)
    end
     
    
    
    myGui = gui.newGui(2, 2, 160, 42, false)
    exitbutton = gui.newButton(myGui, "center", 38, "exit", buttonCallback)
    tButton = gui.newButton(myGui, 1, 2, "Open", toggleRedstone)
    untButton = gui.newButton(myGui, 1, 3, "Close", untoggleRedstone)
    
    gui.clearScreen()
    gui.setTop(prgName .. " " .. version)
    while true do
      gui.runGui(myGui)
    end

     

  3. local component = require("component")
    local upright = component.proxy("ced03056-f8ea-432b-94c0-a89b9d1b3336")--Change the addresses to match with your Redstone I/O's
    local upleft = component.proxy("182fc96d-d245-4bed-a69c-71469b286418")--
    local downright = component.proxy("3d65cc84-e08d-4d32-9c65-b9c9aba60a18")
    local downleft = component.proxy("fc7ebe48-702b-4e1e-9911-5c09c602588c")
    local downright2= component.proxy("1a760530-540e-438a-8cc5-803c75a5767e")
    local downleft2= component.proxy("9de1f13e-4347-408a-bb0a-46f7b2241a15")
    
    
    function close()
    	downleft.setOutput(1,15)
    	downleft.setOutput(3,15)
    	downright.setOutput(1,15)
    	downright.setOutput(3,15)
    	os.sleep(2)
    	upleft.setOutput(5,15)
    	upright.setOutput(4,15)
    end
    
    function open()
    	upleft.setOutput(5,0)
    	upright.setOutput(4,0)
    	os.sleep(2)
    	downleft.setOutput(3,0)
    	downleft.setOutput(1,0)
    	downright.setOutput(3,0)
    	downright.setOutput(1,0)
    	os.sleep(2)
    	downleft2.setOutput(4,15)
    	downright2.setOutput(5,15)
    	downleft2.setOutput(4,0)
    	downright2.setOutput(5,0)
    end

    Let me know what do you think about it

    I just started learning lua like four days ago when I discovered this mod. I know a bit of C and C++. I've been able to do amazing this and I just fall in love with this mod.  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.