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

Proximity Door | Update v1.3 | Nothing says style like an automatic door!

Recommended Posts

AND HIS NAME IS... GANG SINA! Gangsir here again, I've made a simple script that opens a door when a entity from a list moves near an attached motion detector. This acts as both a method of security and an easy way to automatically open a door. It outputs a redstone signal on the top of the computer/RedstoneIO block when a valid entity moves near it.

Usage:

proxdoor [-abli] <time to stay open> [Person1] [Person2]...
Switches:
-a : Accept all mode, door will open for any motion. Whitelist has no effect. Cannot use with -b
-b : Blacklist mode, all provided names the door will ignore, accept all others, cannot be used with -a
-i : Inverted redstone mode, turns redstone on by default and off on detect. Good for piston doors.
-l : Logs all door activity to a file. Useful for security

So, if I wanted the door to stay open for 2 seconds, and allow both me and Sangar to open the door, I would run:

proxdoor 2 Gangsir Sangar

You can have an almost infinite whitelist, limited by your RAM. If you have a very large whitelist, it may be more efficient to run the program in accept all mode or blacklist mode, see above. When setting up, ensure that there is a motion detector on both sides of the door, or it can be seen from both sides. Also ensure it has line of sight, and is within 3 blocks from the door, so that it can trigger. This range can be modified in the program.

 

Screenshots:


ProximityDoorPic.png

The Log file format, if switch -l is used:

Proxdoor%20Logfile.png



Requirements:


+Tier 1 everything
+Redstone card if using computer as output, redstone io block if not
+Motion detector
-Screen only initially, can keep if you want logs on blacklist mode printed to screen, or want to interact with the computer still




The program can be found here:

https://github.com/NoahNMorton/Gangsir_MC_LuaPrograms/blob/master/OpenComputers/HeadlessPrograms/ProximityDoor.lua


Or, Wgetted:

wget https://raw.githubusercontent.com/NoahNMorton/Gangsir_MC_LuaPrograms/master/OpenComputers/HeadlessPrograms/ProximityDoor.lua proxdoor.lua 

As a quick p.s., the program is headless, meaning you can remove all graphics components and it will still function fine. Also recommended if using for security that you protect the blocks around the door, the door itself, and the motion detector to prevent people just busting down the door. I recommend the block protector from RFTools, or Thaumcraft warding.

As always, make sure to like or comment if you enjoy my programs, I'm always happy to see that.

 

Changelog for those who care:

 

V1.0 Added the program.

---

V1.1 Added accept all mode and inverted mode, made whitelist lookup faster. Numerous optimisations.

---

V1.2 Added blacklist mode

---

V1.3 Added file logging on option

---

Link to post
Share on other sites

Its a nice program. A suggestion of mine would be to use a lookup list to speed up the indexing of vaild players. i.e

local players = {

Sangar = true,

Gangsir = true

}

Then...

if players[player.name] then ...

This will be faster than looping the ordered list.

Hope this is helpful :)

Link to post
Share on other sites

Its a nice program. A suggestion of mine would be to use a lookup list to speed up the indexing of vaild players. i.e

-snip-

Hope this is helpful :)

 

Thanks. I'll look into it.

 

Edit: Implemented, speed is noticeably better on larger whitelists. Thanks for the suggestion, keep them coming!

Link to post
Share on other sites

This would be my implementation of my suggestion... Just for shits..

local players = {}
for _, name in pairs(acceptableEntities) do
  players[name] = name
end

local function isValid(name)
  return players[name] and true or false
end

while true do
  local _,_,x,y,z,entity = event.pull("motion")
  if math.abs(x)<= tonumber(range) and math.abs(y)<= tonumber(range) and math.abs(z)<= tonumber(range) then --if recieved motion was within range
      if isValid(entity) then -- entity will always be a string. So will program arguments
        redstone.setOutput(side,15)
        os.sleep(stayOpen)
        redstone.setOutput(side,0)
        break --no need to continue testing if one is valid
      end
  end
end 

I just saw that you made an update while i was mid-post. Almost what I was thinking..

Link to post
Share on other sites

This would be my implementation of my suggestion... Just for shits..

-snip-

I just saw that you made an update while i was mid-post. Almost what I was thinking..

 

Right, that would also work, but I wanted to do it myself, as a learning experience. Thanks for your help though.

Link to post
Share on other sites

I would like to see a version of this with a multi-door setup, such as being able to assign addresses for corresponding inputs and outputs for each setup that goes to one computer which handles it all or a server/client setup that always shows the log on a server monitor deep within the base.

Also I would like to chat sometime to see how you did this as I could not figure out how to extract player info from motion sensor.

 

Link to post
Share on other sites

Join the conversation

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

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