This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Impervium's profile picture

Filtering out certain objects

Started by Impervium, 13 October 2012 - 08:46 PM
Impervium #1
Posted 13 October 2012 - 10:46 PM
Hi

I'm linking the sensorcontroller and sensors to my monitors. So faar I've had GREAT success (can post screenshots if wanted :)/>/> )
Allthough, my problem is I'm too new with Lua to understand how to filter out certain targetsentances.

In my case I've successfully targeted (in order off appearence) these things:
1. Sensorcontroller
2. Sensor (probe)
3. Sensortarget
4. Values from sensortarget

My problem comes in on 3, though on 2 as well but I can manage with only one probe. Problem is, the way I've targeted the target is to target the data spesifically by counting. Though as some of you may know, if I am to target, say, a quarry, the quarry will need to be powered by entities similar to the quarry itself, making the quarry move up or down the list of targets, making the program loose lock on the quarry block, and end up going haywire.


What I need is a way to filter out so data becomes only the targets I'm looking for, like filter all the quarries out of the targetlist and make this the list it goes for, so even if I put up another block, worst thing that can happen is that I make a quarry that will replace the first one on the list, making the program keep running. Understand?

Problem here is as soon as I place a block like a energy link or a cable, the script I made crashes and burns and I got to modify it with the changes made..
And this would create a DMZ (Demilitarized Zone) where I couldn't be able to build anything in risk of fucking up one or more parts of my code to the place it cannot be salvaged anymore..

Suggestions?



targets = sensors.getAvailableTargetsforProbe(ctrl,mainSensor,QuarryProbe)
QuarryTarget = targets[4]
data = sensors.getSensorReadingAsDict(ctrl,mainSensor,QuarryTarget,QuarryProbe)
PixelToast #2
Posted 13 October 2012 - 10:52 PM
you could store the blocks position, then when it changes it will look for that specific block
Impervium #3
Posted 14 October 2012 - 12:20 AM
you could store the blocks position, then when it changes it will look for that specific block
In relevance to the code I pasted, can you post an example on how to do this?
PixelToast #4
Posted 14 October 2012 - 06:32 AM
you could store the blocks position, then when it changes it will look for that specific block
In relevance to the code I pasted, can you post an example on how to do this?
sorry, i dont have ccsensors working atm :C