Gangsir 14 Posted December 12, 2015 Share Posted December 12, 2015 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: The Log file format, if switch -l is used: 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.luaOr, 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 --- Quote Link to post Share on other sites
Molinko 43 Posted December 12, 2015 Share Posted December 12, 2015 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 Quote Link to post Share on other sites
Gangsir 14 Posted December 13, 2015 Author Share Posted December 13, 2015 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! Quote Link to post Share on other sites
Molinko 43 Posted December 13, 2015 Share Posted December 13, 2015 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.. Quote Link to post Share on other sites
Gangsir 14 Posted December 13, 2015 Author Share Posted December 13, 2015 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. Quote Link to post Share on other sites
BrisingrAerowing 12 Posted December 12, 2016 Share Posted December 12, 2016 I've build a daemon based on this, allowing the computer/server to also run other things. Thanks for posting this, though. It is quite cool, and I never would have built mine if this wasn't here. Quote Link to post Share on other sites
jcthiel13 0 Posted June 4, 2017 Share Posted June 4, 2017 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. Quote Link to post Share on other sites
BrisingrAerowing 12 Posted June 4, 2017 Share Posted June 4, 2017 @jcthiel13 I have a daemon / service version of this that allows having multiple doors, as well as allowing plugins for more control over when a door can open. You can find it here. Quote Link to post Share on other sites