#701
Posted 19 February 2013 - 06:43 PM
#702
Posted 19 February 2013 - 10:01 PM
abihoooo, on 19 February 2013 - 06:43 PM, said:
It should always find the API - can I see one of your programs?
#703
Posted 20 February 2013 - 04:31 AM
Mikeemoo, on 19 February 2013 - 10:01 PM, said:
#704
Posted 20 February 2013 - 05:34 AM
#705
Posted 20 February 2013 - 08:08 AM
http://pastebin.com/DH3KE4Yj
#706
Posted 21 February 2013 - 05:59 PM
#707
Posted 22 February 2013 - 09:49 AM
-- you need to wrap your sensor object first -- also assign the name of the entity (your MC user name for example) details = sensor.getTargetDetails(entityName) -- one way to get them out of the target details table: local posX = details.Position.X local posY = details.Position.Y local posZ = details.Position.Z -- alternatively: local posX,posY,posZ = details.Position -- should work
If you're unsure about wrapping peripherals or outputting redstone signals you really need to be looking at the documentation and learning from that as your first port of call. For that stuff we'll only repeat the info that is already readily available to you.
#708
Posted 22 February 2013 - 01:38 PM
tabs, on 22 February 2013 - 09:49 AM, said:
-- you need to wrap your sensor object first -- also assign the name of the entity (your MC user name for example) details = sensor.getTargetDetails(entityName) -- one way to get them out of the target details table: local posX = details.Position.X local posY = details.Position.Y local posZ = details.Position.Z -- alternatively: local posX,posY,posZ = details.Position -- should work
If you're unsure about wrapping peripherals or outputting redstone signals you really need to be looking at the documentation and learning from that as your first port of call. For that stuff we'll only repeat the info that is already readily available to you.
Nah, nah, nah i know about wrapping and outputting. Tnx for explaining about coords!
os.loadAPI("ocs/apis/sensor")
local invent = sensor.wrap("top")
while true do
details = invent.getTargetDetails("Cat")
local posX = details.Position.X
local posY = details.Position.Y
local posZ = details.Position.Z
print("Position X:", posX)
print("Position Y:", posY)
print("Position Z:", posZ)
if posZ >=-3 and posZ <=3 and posX >=-3 and posX <=3 and posY >=-3 and posY <=3 then
redstone.setOutput("left", true)
else
redstone.setOutput("left", false)
end
sleep(0.2)
end
But when i run far away i got
prox:5: attempt to index ? (a nil value)
I think i must add some condition wich will track if player "Cat" in range and then gets position. But i cant realize how.
#709
Posted 23 February 2013 - 04:59 AM
Perhaps a simple:
details = invent.getTargetDetails("Cat")
if details == nil then return
I'm not really up to speed on lua yet, but perhaps this will also work:
if not details then return
#710
Posted 23 February 2013 - 05:49 AM
1. I can't get it to work with the sensorview program, is this a bug or can it not work with that program?
2. Can it detect liquids through a block or two? I'm trying to help setup a sensor that can detect when its safe to raise a piston that is being used to create a pit under a lava fall to prevent the lava from spreading all over the place and lava is notorious for not taking the same amount of time to completely drop from the ceiling once the fall has been shut off.
#711
Posted 23 February 2013 - 09:21 AM
tabs, on 23 February 2013 - 04:59 AM, said:
Perhaps a simple:
details = invent.getTargetDetails("Cat")
if details == nil then return
I'm not really up to speed on lua yet, but perhaps this will also work:
if not details then return
Ummm thats stops program... But u help me with condition
os.loadAPI("ocs/apis/sensor")
local invent = sensor.wrap("top")
local monitor = peripheral.wrap("right")
while true do
details = invent.getTargetDetails("Cat")
if details == nil then
repeat
details = invent.getTargetDetails("Cat")
sleep(0.5)
until details ~= nil
else
local posX = details.Position.X
local posY = details.Position.Y
local posZ = details.Position.Z
print("Position X:", posX)
print("Position Y:", posY)
print("Position Z:", posZ)
if posZ >=-3 and posZ <=3 and posX >=-3 and posX <=3 and posY >=-3 and posY <=3 then
redstone.setOutput("left", true)
else
redstone.setOutput("left", false)
end
end
sleep(0.2)
end
Is here any of huge mistakes wich can do memory leak or some?)
#712
Posted 23 February 2013 - 12:17 PM
Kye_Duo, on 23 February 2013 - 05:49 AM, said:
1. I can't get it to work with the sensorview program, is this a bug or can it not work with that program?
2. Can it detect liquids through a block or two? I'm trying to help setup a sensor that can detect when its safe to raise a piston that is being used to create a pit under a lava fall to prevent the lava from spreading all over the place and lava is notorious for not taking the same amount of time to completely drop from the ceiling once the fall has been shut off.
About 1. : the sonic sensor has many targets (all blocks visible, for a certain definition of 'visible'); sensorview call getTargetsDetails for each, which results in no new intel, but each call takes a tick, so there should be some lag. That's my first attempt at an explanation.
About 2: due to the compact way I implemented it, diagonals are always visible (e.g. (1,1,1) ). So you could check for those, e.g.: wrapped_sensor.getTargetDetails()['1,1,1'] , and still the sensor wouldn't be touching lava. But they are lava-resistant, right? So I guess you want the sensor to be invisible.
It is interesting to let them have a certain see-through power, more than the accidental one, maybe based on the sensor upgrade level.
Also, what do you think about distinguishing between lava and water?
#713
Posted 24 February 2013 - 02:53 AM
Quote
About 1. : the sonic sensor has many targets (all blocks visible, for a certain definition of 'visible'); sensorview call getTargetsDetails for each, which results in no new intel, but each call takes a tick, so there should be some lag. That's my first attempt at an explanation.
About 2: due to the compact way I implemented it, diagonals are always visible (e.g. (1,1,1) ). So you could check for those, e.g.: wrapped_sensor.getTargetDetails()['1,1,1'] , and still the sensor wouldn't be touching lava. But they are lava-resistant, right? So I guess you want the sensor to be invisible.
It is interesting to let them have a certain see-through power, more than the accidental one, maybe based on the sensor upgrade level.
Also, what do you think about distinguishing between lava and water?
that explanation works.
the sensors are being hidden to keep it from being destroyed by mobs, I'm helping my brother make a "danger room" and having exposed sensors would be a bad idea....especially with creepers and Ogres (Mo'Creatures. Thank goodness for construction foam from IC2)
personally I think it should be able to penetrate a few blocks if the sensor is directly against blocks in that direction, and the penetration range should be dependent on the level of the card
distinguishing what type of liquid would be nice, but not needed. though if you set it up right, you could distinguish any type of liquid
#714
Posted 24 February 2013 - 07:22 AM
Every time I call sensor.getTargetDetails(k) using the BC sensor it appears a new object is created (according to the console from the FTB launcher). Does OpenCCSensors handle the destruction of these objects? Does the data get passed to CC and the object immediately destroyed?
I suppose I have two concerns here. One is that I'm not causing too many garbage collections, the other that I need better performance out of my app.
Would there be a way of reusing the tile object to get more recent data, rather than creating a new one? Not really sure what limitations you're working under writing mods like this. There seems to be so many layers of abstraction.
#715
Posted 24 February 2013 - 09:39 AM
Kye_Duo, on 24 February 2013 - 02:53 AM, said:
tabs, on 24 February 2013 - 07:22 AM, said:
#716
Posted 24 February 2013 - 10:23 AM
CoolisTheName007, on 24 February 2013 - 09:39 AM, said:
tested and it doesn't seem to work...keeps returning a number that increases for every sensor subfunction we use.
#717
Posted 24 February 2013 - 01:34 PM
#718
Posted 24 February 2013 - 04:00 PM
Lyqyd, on 24 February 2013 - 01:34 PM, said:
#719
Posted 24 February 2013 - 05:44 PM
if not os.loadAPI("ocs/apis/sensor") then print("Cannot load API!") return end
local sens
for _, side in pairs(rs.getSides()) do
if peripheral.isPresent(side) and peripheral.getType(side) == "sensor" then
print("Sensor found on "..side.." side.")
sens = sensor.wrap(side)
break
end
end
if not sens then print("Could not detect sensor!") return end
print("Sensor type is: "..sens.getSensorName())
local targets = sens.getTargets()
local targetNames = {}
for k, v in pairs(targets) do
table.insert(targetNames, k)
end
print("Found "..#targetNames.." targets.")
print("Printing targets momentarily.")
sleep(2)
textutils.pagedTabulate(targetNames)
I'm curious to see what it outputs with your sonic sensor, and with the same setup with the card swapped out for a player detector card.
#720
Posted 25 February 2013 - 04:09 AM
Lyqyd, on 24 February 2013 - 05:44 PM, said:
if not os.loadAPI("ocs/apis/sensor") then print("Cannot load API!") return end
local sens
for _, side in pairs(rs.getSides()) do
if peripheral.isPresent(side) and peripheral.getType(side) == "sensor" then
print("Sensor found on "..side.." side.")
sens = sensor.wrap(side)
break
end
end
if not sens then print("Could not detect sensor!") return end
print("Sensor type is: "..sens.getSensorName())
local targets = sens.getTargets()
local targetNames = {}
for k, v in pairs(targets) do
table.insert(targetNames, k)
end
print("Found "..#targetNames.." targets.")
print("Printing targets momentarily.")
sleep(2)
textutils.pagedTabulate(targetNames)
I'm curious to see what it outputs with your sonic sensor, and with the same setup with the card swapped out for a player detector card.
Was able to run your example code with the following output:
Sensor found on top side. Sensor type is: openccsensors.item.sonicsensor
And then nothing. No error generated, just ends. My guess is that it silently errors at the line "local targets = sens.getTargets()", or that the table targets is empty.
And the output of the proximity sensor card:
Sensor found on top side. Sensor type is: openccsensors.item.proximitysensor Found 1 targets. Printing targets momentarily. TheGeek007
What next?
Edited by TheGeek, 25 February 2013 - 04:22 AM.
6 user(s) are reading this topic
0 members, 6 guests, 0 anonymous users











