28 posts
Posted 19 December 2012 - 01:25 PM
So im working on a large display for my factory that tells me lots of useful things with ccSensors. One of the things I would like it to tell me is when its time to replace uranium cells (I don't want this automated). since uranium cells have a damage value for how full they are I thought I would reference that (1-10000 going strong, 10000-15000 replace cells soon, 15000-20000 cells almost dead, 0/missing cell dead).
The problem with this is I have no idea how to get the damage information out of the reactor contents to print or manipulate, any tips?
2005 posts
Posted 19 December 2012 - 04:29 PM
Use textutils.serialize() or textutils.tabulate() to print out tables. That should allow you to figure out the parts you want and how best to grab them.
249 posts
Location
In the universe
Posted 19 December 2012 - 04:32 PM
or you can use a for loop
Example:
for i = 1, #nameOfTheTable do
print(nameOfTheTable[i])
end
28 posts
Posted 19 December 2012 - 05:52 PM
or you can use a for loop
Example:
for i = 1, #nameOfTheTable do
print(nameOfTheTable[i])
end
I was trying this earlier, but it leaves me with a string, it contains all the info (item name, tile or item, and damage). However, I don't know how to get the numbers out of the string, and even if I did, wouldnt it still be a string? math cant be performed on strings and would need to be converted to an int, correct?
8543 posts
Posted 19 December 2012 - 06:15 PM
There are a couple topics floating around with a string.match pattern to use to get this exact information out. Basically, since the structure of the information is consistent, the string can be matched against a pattern to pull certain pieces of data out. You can then tonumber() the extracted damage value and perform whatever operations are needed. Search for "ccsensors string.match" and it should be in some of the more recent results. In fact, I believe you can search through Espen's posts specifically to find the reply I'm thinking of.