Posted 08 July 2013 - 07:58 PM
Title: Openccsensor question
Hiya folks, newbie programmer here…just had a question about openccsensors…
The code that I have for activating a redstone output (for a door, or a tesla coil, the two of whiuch are going to be what the code is doing, and that i also shamelessly ripped right from the openccsensor wiki entry) is more or less straightforward, but there are 2 things that i would like to ask…
1. how can i make the sensor activate ONLY for players, and to go a bit further, only for SPECIFIC players? (im looking for an answer to both of these, please and thank you)
and
2. This section
local proximity = sensor.wrap("left")
while true do
local signal = false
local targets = proximity.getTargets()
for k, v in pairs(targets) do
if distance(v.Position) < radius then
signal = true
end
end
has me slightly confused…alow me to please run down what i know here
the first line is designating the sensor name (proximity) and telling the computer where it is, thats easy…
the second line, my guess, is that its telling the computer that if the sensor is there it is to do the following…yes?
third line is setting a variable, signal, but i dont know what false is…does it just mean that its setting no players in range as a variable? dont quite understand
fourth line, straightforward, setting the target list as a variable (and im atleast half certain that this is what i would have to play around with to set only players to activate the sensor
5th line…this one is the one that got me….k? v in pairs? might as well be a foreign language for as much as i can figure this bit out.
6th line, checking if the distance between the target and the door is less than the radius i set earlier in the code, easy
7th line, setting the signal to true, letting computer know that yes, its time to activate the redstone?
any and all help with this would be appreciated, LUA seems easy enough, but the little obscure bits her are the ones that im going to have a problem with
Thanks!
P.s. if any of you are going to post code for me to see, please comment as much of it as you can, it really helps….thanks again!
Hiya folks, newbie programmer here…just had a question about openccsensors…
The code that I have for activating a redstone output (for a door, or a tesla coil, the two of whiuch are going to be what the code is doing, and that i also shamelessly ripped right from the openccsensor wiki entry) is more or less straightforward, but there are 2 things that i would like to ask…
1. how can i make the sensor activate ONLY for players, and to go a bit further, only for SPECIFIC players? (im looking for an answer to both of these, please and thank you)
and
2. This section
local proximity = sensor.wrap("left")
while true do
local signal = false
local targets = proximity.getTargets()
for k, v in pairs(targets) do
if distance(v.Position) < radius then
signal = true
end
end
has me slightly confused…alow me to please run down what i know here
the first line is designating the sensor name (proximity) and telling the computer where it is, thats easy…
the second line, my guess, is that its telling the computer that if the sensor is there it is to do the following…yes?
third line is setting a variable, signal, but i dont know what false is…does it just mean that its setting no players in range as a variable? dont quite understand
fourth line, straightforward, setting the target list as a variable (and im atleast half certain that this is what i would have to play around with to set only players to activate the sensor
5th line…this one is the one that got me….k? v in pairs? might as well be a foreign language for as much as i can figure this bit out.
6th line, checking if the distance between the target and the door is less than the radius i set earlier in the code, easy
7th line, setting the signal to true, letting computer know that yes, its time to activate the redstone?
any and all help with this would be appreciated, LUA seems easy enough, but the little obscure bits her are the ones that im going to have a problem with
Thanks!
P.s. if any of you are going to post code for me to see, please comment as much of it as you can, it really helps….thanks again!