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

Need help with a variable

Started by Divion, 29 June 2013 - 03:34 PM
Divion #1
Posted 29 June 2013 - 05:34 PM
Hi, this is one of my first programs, so i dont really know a lot of CC other that some of the wiki contents.
I want to be able to say a function followed by a variable, where the variable is a string that completes the rs.setBundledOutput("back", here goes the variable). So i created the 3 variables i need, but i dont know how to say to the command to fill the space there.

--Variables
local move = "colors.white"
local deploy = "colors.black"
local bb = "colors.cyan"
--Function
function pulse()
  rs.setBundledOutput("back", --i need the variable here
  sleep(0.5)
  rs.setBundledOutput("back", 0)
end
--Program
function MainProg
  count = 0
  while true do
	count = count + 1
	pulse(move)
	sleep(4)
	pulse(deploy)
	sleep(27)
	pulse(bb)
	sleep(1)
	print ("Finished : "..count)
end
MainProg()
Sorry for my bad english, sometimes its hard to write what i want.
Lyqyd #2
Posted 30 June 2013 - 02:17 AM
Split into new topic.

If you want to have all three lines on at once, you'd want to use colors.combine to put them together:


rs.setBundledOutput("back", colors.combine(move, deploy, bb))
M4sh3dP0t4t03 #3
Posted 30 June 2013 - 07:23 AM
I think the thing he wants is
 function pulse(color)
  rs.setBundledOutput("back", color)
  sleep(0.5)
  rs.setBundledOutput("back", 0)
end
Apfeldstrudel #4
Posted 30 June 2013 - 09:03 AM
I think the thing he wants is


rs.setBundledOutput("back",bb,true)
Lyqyd #5
Posted 30 June 2013 - 01:55 PM
I think the thing he wants is
 function pulse(color)
  rs.setBundledOutput("back", color)
  sleep(0.5)
  rs.setBundledOutput("back", 0)
end

Yeah, looks like that's probably what he needs. I skimmed the code a bit quicker than usual. :P/>

I think the thing he wants is


rs.setBundledOutput("back",bb,true)

That's not how you use the setBundledOutput function. Please don't add incorrect information.
Divion #6
Posted 30 June 2013 - 04:59 PM
Thank you, it was what i was looking :D/>