#1
Posted 09 January 2013 - 02:19 PM
I am trying to add a player detector to my password door so i know who tryed to access it, but what i cant figure out is how to actually make it write to a list on another program. Can anyone help me?
Thanks!
-Will
#2
Posted 10 January 2013 - 09:14 AM
dobbylego, on 09 January 2013 - 02:19 PM, said:
I am trying to add a player detector to my password door so i know who tryed to access it, but what i cant figure out is how to actually make it write to a list on another program. Can anyone help me?
Thanks!
-Will
#3
Posted 10 January 2013 - 09:46 AM
dobbylego, on 09 January 2013 - 02:19 PM, said:
I am trying to add a player detector to my password door so i know who tryed to access it, but what i cant figure out is how to actually make it write to a list on another program. Can anyone help me?
Thanks!
-Will
Save it to a file, then the other program can read in the file and do what it wants with that data?
#4
Posted 10 January 2013 - 03:11 PM
crazyguymgd- Ya how would I do that?
#5
Posted 10 January 2013 - 04:36 PM
#6
Posted 10 January 2013 - 06:24 PM
os.loadAPI("ocs/apis/sensor") s=sensor.wrap(sSide) for k,v in pairs(s.getTargets()) do print("Username: "..k.."\nCDS: "..v.Position.x..", "..v.Position.Y..", "..v.Position.Z.."\n") end
and it will print out a list of detected players and their position relative to the sensor, your position is the one you need. in your actual password protecting program use coroutines to only allow people to enter a password if they are in that area (you can make it span multiple blocks). make your password protecting code into a function which accepts a parameter for the player name that way you can greet the player when you ask them for their password
os.loadAPI("ocs/apis/sensor") local x=yourX local y=yourY local z=yourZ local sense=coroutine.wrap(function() local s=sensor.wrap(sensorside) while true do local tResults=s.getTargets() for k,v in pairs(tResults) do if v.Position.X==x and v.Position.Y==y and v.Position.Z==z then coroutine.yield(k) break end end sleep(0.5) end end) local pass=nil local running=false local evts={} while true do local r=sense(unpack(evts)) if type(r)=="string" and running then pass(unpack(evts)) elseif type(r)=="string" and not running then pass=coroutine.wrap(yourpasswordfunction) pass(r) running=true elseif type(r)~="string" and running pass=nil running=false end local evts={os.pullEvent()} end
basically what that should do is run a coroutine constantly checking positions of detected players, if one is at the required position then it starts the 'yourpasswordfunction' function and keeps running it until there is no longer a player detected there, if no-one is there and then someone arrives then it starts the function over from the beginning
if you do not understand or if you have trouble executing any of the above feel free to ask
#7
Posted 11 January 2013 - 06:14 PM
#8
Posted 12 January 2013 - 02:06 AM
#9
Posted 12 January 2013 - 02:00 PM
#10
Posted 13 January 2013 - 02:02 AM
on line 13 I forgot something. just before the yield you need an os.queueEvent('someBShere') so that it resumes the coroutine.yield(), now that I think about it there is a better way to do this but this method would work too
#11
Posted 13 January 2013 - 02:14 AM
http://www.computerc...peripherals-23/
It sais it emits the event "player" when someone right clicks it, with the player name as parameter.
so using something like
p = peripheral.wrap("<side>") player, p1 = os.pullEvent() print(p1)
should print the players name, I hope this helps out
#12
Posted 13 January 2013 - 02:38 AM
W00dyR, on 13 January 2013 - 02:14 AM, said:
http://www.computerc...peripherals-23/
It sais it emits the event "player" when someone right clicks it, with the player name as parameter.
so using something like
p = peripheral.wrap("<side>") player, p1 = os.pullEvent() print(p1)
should print the players name, I hope this helps out
Yes, p1 will be the username of the player that right clicks it, and player would be the event 'player'.
No need for wrapping it though.
#13
Posted 17 January 2013 - 01:21 PM
#14
Posted 27 March 2013 - 12:55 PM
#15
Posted 27 March 2013 - 05:20 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users