I see! I didn't really understand that you were calling the iterator at first, but now it makes sense. Thanks! Also thank you for the advice, I knew already. I kinda just grabbed the example from the component API page on the wiki.
I wasn't sure this belonged in the normal question areas being this was more of a general curiosity than it was useful info, so I came here. But enough beating around the bush. My question is: Why, when using do you need to add in the orange (colored for convenience) parentheses? I'm sure there's a bit of obviousness I'm probably missing, with my patchwork amount of programming knowledge.
So, I'm attempting to assign unique variables for a multi-component counting program to try to make a simple monitoring program through Adapted blocks and Industrial Craft Classic energy storage blocks. (BatBox, MFE, and MFSU) At first I thought maybe I could concatenate the variable and an index number to do a simple unique variable per address called, like mfsu1, mfsu2, mfsu3, etc. But, that didn't quite work, and resulted in an error. I'm a bit stumped as to what to do about it. I searched for it as best as I could describe it, and couldn't find an answer on it. I'm sure there's some way to do it, but I'm not quite sure what it would be called, or if I'm even going about it the right way. But anyway, could someone provide me with a solution or a workaround? I'm in the Tekkify: Refored pack if that makes any difference, and it's running OC 1.5 as far as I know. Here's my code as is (with bad code included) cm = require("component") local i = 1 local cnm = "mfsu" for a,m in cm.list(cnm) do m .. tostring(i) = a print(m .. tostring(i)) i = i + 1 end I apologize if I seem a bit dumb trying that, but I was a bit lost on how to proceed. Any and all help would be appreciated!
Thank you for pointing that out! I ah, didn't quite think to do that. Bah. But aside from that, I've come into a new problem. When I start the program now, just as you have it above, it updates it just once, showing it as it is the first time it checks it, and then loops again, but doesn't update the values of the RPM and others. I even checked by increasing and decreasing the RPM to confirm it. That is a bit of a crucial part of the monitoring, so I would like to know what is wrong if anything is. Again, thank you in advanced!
Ok, so, I'm playing on a modpack (Tekkify) that has both Big Reactors and OpenComputers, and I'm trying to write a program that monitors a turbine I have set up after I start the program. I sadly don't know a lot about lua or OC on my own to fix this, so I'm looking to get some help possibly from people who have more know-how on with OC. I've already written up a rough mock of what I want, though it doesn't quite work as I had imagined-- it goes through the program once, prints the items I'm attempting to track to the screen once, I was using a while loop to hopefully make it check the values over and over, but it doesn't seem to be doing that. local term = require("term") local component = require("component") local turbine = component.br_turbine local tActive = turbine.getActive() local tRPM = math.ceil(tonumber(turbine.getRotorSpeed())) local tRf = math.ceil(tonumber(turbine.getEnergyStored())) local tRfPt = math.ceil(tonumber(turbine.getEnergyProducedLastTick())) while tActive do os.sleep(1) term.clear() print(tRPM, " RPM") print(tRf, " RF Stored") print(tRfPt, " RF/t") end If, due to my lack of knowledge of how loops work other than them just looping, I actually did what I was hoping for wrong, please, tell me how I can fix it so I might learn for future instances. Thank you in advance!