#521
Posted 21 January 2013 - 05:24 AM
#522
Posted 21 January 2013 - 08:40 AM
I know i have to compare the slot with the armor item i think its: "item.hazmat.suit". all i want to do is understand how to use the getTargetDetails command
#523
Posted 21 January 2013 - 09:11 AM
Mikeemoo, on 21 January 2013 - 12:08 AM, said:
I was using railcraft liquid loaders and iron tanks, but buildcraft liquid tanks are doing the same thing.
#524
Posted 21 January 2013 - 10:13 AM
TheModerGuy, on 21 January 2013 - 08:40 AM, said:
I know i have to compare the slot with the armor item i think its: "item.hazmat.suit". all i want to do is understand how to use the getTargetDetails command
When you use the getTargetDetails command it returns a table of the target you specified. Then you get the variables out using the key. So for example to get the chest plate you would type table["Armour"]["Chestplate"]["Name"] and it would return the name of the item you have in the chest slot. Come example code to print out your armor would be
os.loadAPI("ocs/apis/sensor")
s = sensor.wrap(side)
target = s.getTargetDetails(loc)
for k, v in pairs(target.Armour) do
write(k..": ")
print(v["Name"])
end
#525
Posted 21 January 2013 - 05:29 PM
abihoooo, on 21 January 2013 - 10:13 AM, said:
TheModerGuy, on 21 January 2013 - 08:40 AM, said:
I know i have to compare the slot with the armor item i think its: "item.hazmat.suit". all i want to do is understand how to use the getTargetDetails command
When you use the getTargetDetails command it returns a table of the target you specified. Then you get the variables out using the key. So for example to get the chest plate you would type table["Armour"]["Chestplate"]["Name"] and it would return the name of the item you have in the chest slot. Come example code to print out your armor would be
os.loadAPI("ocs/apis/sensor")
s = sensor.wrap(side)
target = s.getTargetDetails(loc)
for k, v in pairs(target.Armour) do
write(k..": ")
print(v["Name"])
end
Thank you good sir!!
this would of been apparent if my build of ccsensors was not broken :3
Edited by TheModerGuy, 21 January 2013 - 05:34 PM.
#526
Posted 21 January 2013 - 06:02 PM
os.loadAPI("ocs/apis/sensor")
s = sensor.wrap("right")
target = s.getTargetDetails(s.getTarget())
print(k.." : "..v)
end
#527
Posted 21 January 2013 - 06:46 PM
TheModerGuy, on 21 January 2013 - 06:02 PM, said:
os.loadAPI("ocs/apis/sensor")
s = sensor.wrap("right")
target = s.getTargetDetails(s.getTarget())
print(k.." : "..v)
end
Not sure what you're trying to do here. getTargets will return a table of targets, and getTargetDetails will give you details for a single one of those targets. Perhaps you're trying to do something vaguely thus:
os.loadAPI("ocs/apis/sensor")
s = sensor.wrap("right")
targets = s.getTargets()
for k, v in pairs(targets) do
print(k)
for dk, dv in pairs(s.getTargetDetails(k)) do
print(dk.." : "..dv)
end
end
You need to loop through the tables that it returns if you're trying to print out elements from those tables.
#528
Posted 21 January 2013 - 09:43 PM
#531
Posted 22 January 2013 - 08:40 AM
#532
Posted 22 January 2013 - 09:20 AM
I've got this setup :
#533
Posted 22 January 2013 - 09:22 AM
It's to do with the whole multi-block system..
(actually, if you're playing this just in single player I'm happy to send across a custom build with the fix in)
#534
Posted 22 January 2013 - 02:22 PM
#535
Posted 22 January 2013 - 07:36 PM
Mikeemoo, on 22 January 2013 - 09:22 AM, said:
It's to do with the whole multi-block system..
(actually, if you're playing this just in single player I'm happy to send across a custom build with the fix in)
Thnx for the offer, but we're playing SMP, on the other hand we do have 3.06b of Misc Peripherals and a backup system on the server. So I don't think that any real harm could be done
btw I really LOVE the gauges!!
#536
Posted 22 January 2013 - 09:55 PM
abihoooo, on 22 January 2013 - 02:22 PM, said:
Any crash log you can supply would be a huge help so I can make sure it's all sorted for the next release.
#537
Posted 22 January 2013 - 11:56 PM
I seem to be having a problem with the proximity sensor when a player goes out of range whilst the program is still iterating through the table returned by getTargets().
Take this code, for example...
os.loadAPI("ocs/apis/sensor")
local proximity = sensor.wrap("top")
repeat
local targets = proximity.getTargets()
term.clear()
print("Players in range:-")
for name, details in pairs(targets) do
if details.Type == "Player" then
local fullDetails = proximity.getTargetDetails(name)
if fullDetails then
print(fullDetails.Username)
end
end
end
until false
With version 0.1.0, getTargetDetails() would simply return null. This was easy to deal with, as can be seen above.
Unfortunately, version 0.1.2 now chucks up the following error message instead...
sensor:8: Please specify a valid targetname
If this is intended behaviour, I'd really appreciate it if someone could show me the best way to deal with this situation.
Thanks in advance.
#538
Posted 23 January 2013 - 12:04 AM
That's a bit of an oversight on my part. I've tried to add nicer error handling in there, but I guess some things should return null instead of errors..
The offending code will be in:
/ocs/apis/sensor
you can see that if the peripheral throws an ocs_error event, it'll throw an error() in the lua.
I can fix this for the next release, however, as a workaround I recommend one of the two:
1) copy ocs/apis/sensor down to the root of your computer and edit that lua method there so it returns null instead of throwing an error
or..
2) use pcall on the sensor instead.
<immibis> pcall(function, arguments...) -> status, return_values... <immibis> status is true for success, false for error <immibis> if it errored, there'll be one return_value, and that's the error message
#540
Posted 23 January 2013 - 12:17 AM
Thanks Mikeemoo, I'll do as suggested.
Cheers.
[edit]
You posted again as I was replying.
That's great. Thanks *very* much.
[/edit]
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users














