local component =require("component")local sensor = component.motion_sensor
local sides =require("sides")local io =require("io")local term =require("term")localevent=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)dolocal rs = component.proxy(address)
rs.setOutput(sides.top,15)endendfunction open()for address in component.list("redstone",true)dolocal 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)endfunction openMan()
open()print("Closing it in 8 seconds")
os.sleep(8)
close()endfunction detect()print("Detecting...")whiletruedolocal _,_,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)thenif name =="AetherEus"then
open()print("Detected:",name)print("Closing the staircase in 10 seconds")
os.sleep(10)
close()returnfalseendendendend
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==1then term.clear()print("Aileen: Opening.") openMan() os.sleep(1) detect()endif inst==2then term.clear()print("Aileen: Starting detection mode.") detect()endif inst==4then term.clear()print("Aileen: Closing the program.") term.clear()endif inst==3then term.clear()print("Aileen: Closing the staircase.") close()enduntil inst ==4elseprint("Plug in the motion sensor!!!")endreturn0
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.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
This is the program.
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.
Link to post
Share on other sites