Jump to content




red power bundled cables input


  • You cannot reply to this topic
9 replies to this topic

#1 Lasere123456

  • Members
  • 30 posts

Posted 26 July 2012 - 03:17 PM

Hello people:D
i just found this mod 5 days ago and have been studying programming ever since!

At the moment i am working on a control panel controlling 5 different systems.
it is in working condition (it can toggle stuff on or off atm), but i want to add a indicator for each system.
so since i knew bundled cables are a pain to work whit i did a experiment.

if rs.getBundledInput("back", colors.white ) then
print("white wire is on")
elseif rs.getBundledInput("back", colors.orange ) then
print("orange wire is on")
else
print("No wire is on")
end

but i always outputs:
White wire is on

always!!

#2 OmegaVest

  • Members
  • 436 posts

Posted 26 July 2012 - 03:25 PM

Okay, so getBundledInput just outputs a number. If White is on, then it will be 1, while if orange is on it's 2. Both being on makes it 3. Binary counting.

So, to get what you are looking for, you can either capture the number to a variable and check for the number to match what you are looking for. Or you can use testBundledInput, which is probably what you wanted in the beginning, as it uses those parameters.

#3 Lasere123456

  • Members
  • 30 posts

Posted 26 July 2012 - 03:37 PM

Thx, mate after some searching after the test bundle ting i found the code i needed:

print(redstone.testBundledInput("back", colors.white))


#4 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 26 July 2012 - 08:16 PM

Furthermor, wou can make that code a little "shinier" by setting it up this way:
function colorTest(side, color)
  if (redstone.testBundledInput("side", colors.color)) = true then
  print(color, " wire is on.")
  elseif (redstone.testBundledInput("side", colors.color)) = false then
  print(color, " wire is off.")
  end
end
you should be able to call back to that function several times with any color/side you want by inputting colorTest(side, color) wherever you want, and replacing the side and color appropriately.

#5 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 26 July 2012 - 09:12 PM

Just fixing your code a bit..
function colorTest(side, color)
  if rs.testBundledInput(side, colors.color) then
    print(color .." wire is on.")
  elseif rs.testBundledInput(side, colors.color) then
    print(color .." wire is on.")
  end
end


#6 OmegaVest

  • Members
  • 436 posts

Posted 26 July 2012 - 09:20 PM

Actually, the commas would have worked as well. And, in cases where you are trying to concatenate numbers and strings, they are the only way to go (with print, that is).

#7 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 26 July 2012 - 09:22 PM

Yes but his code wouldn't of worked because of the "= true" not "== true" or just nothing. More efficient: rs.* and no = true.

#8 OmegaVest

  • Members
  • 436 posts

Posted 26 July 2012 - 09:30 PM

I wasn't disputing that. Just, a quirk of mine: I make code work for everything, even if I'm only using it in a very specific way, and only on SSP. So, I commented about commas versus concatenation.


EDIT: Which, by the way, sounds awesome if you say it out loud. Like a cheesy coder debate topic.

#9 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 26 July 2012 - 11:58 PM

thanks for the fix....i guess??? was it wrong or not, i'm confused...

#10 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 27 July 2012 - 12:20 AM

Here's a version that would actually work:

function colorTest(side, color)
  if redstone.testBundledInput(side, colors[color]) then
	print(color.." wire is on.")
  else
	print(color.." wire is off.")
  end
end






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users