Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
GodlyPlexi

Unique Variables Made Through For Do Loop

Question

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!

Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.