#501
Posted 20 January 2013 - 11:26 AM
its a debugging tool that should give you more information. I can't help much tonight but i'll be around tomorrow if you still need help!
#502
Posted 20 January 2013 - 11:54 AM
#503
Posted 20 January 2013 - 11:58 AM
#504
Posted 20 January 2013 - 12:30 PM
Trying to write a quick program to print the name of nearby inventory items (chests), type of item in a chest, and the number of each item.
To clarify, I'm expecting to finish up with something along the lines of;
'Found Object: Chest
Item: Dirt 2, Cobblestone 4'
or something like that.
This is my current code (to build upon)
os.loadAPI("ocs/apis/sensor")
invsensor = sensor.wrap("right")
local targets = invsensor.getTargets()
for name, basicDetails in pairs(targets) do
print("Found Object: "..name)
local moreDetails = invsensor.getTargetDetails(name)
print("Item: "..moreDetails.<Something>)
end
Commenting out the final 'print' line, it yields two things out; 'Found Object: 0,0,0' & 'Found Object: 0,0,-1'.
So here's my first problem, why has 'name' called the location of the items (relative to the sensor) as opposed to the block names (the chest)?
Secondly, what would I put in place of '<Something>' to output the size? I attempted 'Size' & 'size' as SensorView would seem to make it look like, but was greeted with errors.
Cheers,
Cosford.
#505
Posted 20 January 2013 - 12:36 PM
as for name,, Location whud be a better term
for name, basicDetails in pairs(targets) do
print("Found Object at : "..name)
local moreDetails = invsensor.getTargetDetails(basicDetails )
for k,v in pairs (moreDetails )
write("Item: "..v.Name.." : "..v.Size)
end
#506
Posted 20 January 2013 - 01:05 PM
--foundary input control V0.1
os.loadAPI("ocs/apis/sensor")
scanner = sensor.wrap("top")
--configurable variables
scanDelay = 5
--main loop
while true do
scan = scanner.getTargets()
print(textutils.serialize(scan))
scanGreen = scanner.getTargetDetails("1,0,1")
print(textutils.serialize(scanGreen))
print(scanGreen.[1].Size)
scanBlue = scanner.getTargetDetails("-1,0,1")
scanWhite = scanner.getTargetDetails("-1,0,-1")
scanRed = scanner.getTargetDetails("1,0,-1")
sleep(scanDelay)
end
I get the error
bios:338: [string"foundryCC.lua"]:12: '<name>' expected
I think i'm not formatting the 'key' correctly. HEEELP!
#508
Posted 20 January 2013 - 01:31 PM
Attached Files
#509
Posted 20 January 2013 - 02:27 PM
TheGeek, on 20 January 2013 - 01:31 PM, said:
Should be fixed. download a fresh copy
#510
Posted 20 January 2013 - 03:02 PM
#511
Posted 20 January 2013 - 04:10 PM
abihoooo, on 20 January 2013 - 03:02 PM, said:
They certainly were, but that was supposed to be fixed. I guess I'll yell at Mikee again at some point!
#512
Posted 20 January 2013 - 07:20 PM
#513
Posted 21 January 2013 - 12:08 AM
abihoooo, on 20 January 2013 - 07:20 PM, said:
I'll take a look at the combustable thing. I'm sure we had that fixed...
As for tanks, which tanks are you using? each mod implement the tanks differently, and unfortunately some dont implement it right!
#514
Posted 21 January 2013 - 12:58 AM
I always try to use update version of mods
#515
Posted 21 January 2013 - 01:06 AM
abihoooo, on 20 January 2013 - 07:20 PM, said:
Download a fresh copy of 0.1.2, i've put a fix in to try stop them setting on fire. It seems industialcraft doesnt pay much attention to what is/isn't flammable, so this fix may not have worked.
If that fails, all I can suggest for now is moving your sensor at least 3 blocks away from the reactor. The range of the reactor is a 5x5x5 cube, so use a mk2+ sensor card
#516
Posted 21 January 2013 - 01:39 AM
os.loadAPI("ocs/apis/sensor")
invsensor = sensor.wrap("right")
local targets = invsensor.getTargets()
for name, basicDetails in pairs(targets) do
print("Found Object: "..name)
local moreDetails = invsensor.getTargetDetails(name)
for slotId, slotDetails in pairs(moreDetails.Slots) do
print("Slot ".. slotId.." : "..slotDetails.Name.. "(".slotDetails.Size.")")
end
end
Or if you're looking to tally them all up (instead of outputting exactly what's in each slot)
os.loadAPI("ocs/apis/sensor")
-- wrap the sensor
local invent = sensor.wrap("left")
-- get all the targets
local targets = invent.getTargets()
-- 'name' here could be called anything. the value that
-- is returned is a unique identifier for that particular block
-- most sensors use their position as the name because it's
-- always going to be unique for that chest. it's just a unique
-- key you can use as an identity
for name, basicDetails in pairs(targets) do
-- if 'type' prints out something unexpected (like a 3 character word), try
-- downloading a fresh copy of OpenCCSensors or update this in your languages
-- file
print("found inventory of type: "..basicDetails.Type)
-- now we get the full details using that key ('name') as the parameter. this is
-- this is why it has to be unique
local fullDetails = invent.getTargetDetails(name)
-- This is a blank object that'll tally up the different types of each item in each slot
local itemTally = {}
-- loop through the slots
for slotId, slotDetails in pairs(fullDetails.Slots) do
-- get the name of the item
local itemName = slotDetails.Name;
-- if the slot isnt empty
if nameName ~= "empty" then
-- if we've not yet had that item in the tally
-- lets set it to 0
if itemTally[itemName] == nil then
itemTally[itemName] = 0
end
-- now increase the size of the tally for that item
itemTally[itemName] = itemTally[itemName] + slotDetails.Size
end
end
-- loop through the tally
for itemName, itemCount in pairs(itemTally) do
-- print out the name and the count
print(itemName.." : "..itemCount)
end
print("")
print("")
end
If you look at sensorview again, you should be able to see that Slots is a property of the table, which is a table in itself
#517
Posted 21 January 2013 - 05:02 AM
#518
Posted 21 January 2013 - 05:03 AM
#519
Posted 21 January 2013 - 05:13 AM
Man, I really need to finish getting set up for working on the java-side code.
#520
Posted 21 January 2013 - 05:22 AM
Lyqyd, on 21 January 2013 - 05:13 AM, said:
Man, I really need to finish getting set up for working on the java-side code.
Not yet. I'm still learning about a lot of these mods as I go
btw, compiling a big list of every block from every major mod that OCS can interface with. It'd be good to put this in the first post (in a spoiler) when its done
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












