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

Everytime I try to enter an input, (a diff. input combines diff. Colors) nothing happens (the colors don't even combined)

Started by n1ghtk1ng, 06 September 2012 - 09:37 PM
n1ghtk1ng #1
Posted 06 September 2012 - 11:37 PM
Link to Code : http://pastebin.com/hGEtwYMA

Thanks for your help! :D/>/>

PS, This is my first programming language, The only help I've gotten is from here + Wikis, so it would be great if you'd improve my code. Thanks Again :P/>/>

PPS, I've only programmed for 2 weeks.
OmegaVest #2
Posted 07 September 2012 - 12:04 AM
So, for starters, you never change OP. You call it many times, but never tell it to be something else.

And if block like the ones you are trying to make would look a bit more like this:


if input == choide then
   if rs.testBundledInput(side, color) then
	  rs.setBundledOutput(side, colors.subtract(OP, color))
	  OP = colors.subtract(OP, color)
   else
	  rs.setBundledOutput(side, colors.combine(OP, color))
	  OP = colors.combine(OP, color)
   end
end



Get back to me when you have done this and tested it. If you conform to this method, it should work out lovely. Also, reboots kill all variables. Don't use them. Use a while loop.
n1ghtk1ng #3
Posted 07 September 2012 - 12:23 AM
So, for starters, you never change OP. You call it many times, but never tell it to be something else.

And if block like the ones you are trying to make would look a bit more like this:


if input == choide then
   if rs.testBundledInput(side, color) then
	  rs.setBundledOutput(side, colors.subtract(OP, color))
	  OP = colors.subtract(OP, color)
   else
	  rs.setBundledOutput(side, colors.combine(OP, color))
	  OP = colors.combine(OP, color)
   end
end



Get back to me when you have done this and tested it. If you conform to this method, it should work out lovely. Also, reboots kill all variables. Don't use them. Use a while loop.

This is what I have so far :


while 1 ~= 0 do
input = read()
if input == "engines" then
if rs.testBundledInput(side, 1) then
  print("Turning Engines Off")
  rs.setBundledOutput(side, colors.subtract(OP, 1))
  OP = colors.subtract(OP, 1)
else
  rs.setBundledOutput(side, colors.combine(OP, 1))
  print("Turning Engines On")
  OP = colors.combine(OP, 1)
end
end
end


EDIT: Is there anyway I can save it in a different file like I did previously, so that when I leave Minecraft, and get back on my save and turn on my computer, everything that I had on previously would be on?
Caracca #4
Posted 07 September 2012 - 09:56 AM
best is to use a 3rd party program like notepad++ for that.
That is, if you mean you are talking about editing the files you've previously used, or are you talking about the minecraft computer autostarting the program you've being working on ?
n1ghtk1ng #5
Posted 07 September 2012 - 12:27 PM
best is to use a 3rd party program like notepad++ for that.
That is, if you mean you are talking about editing the files you've previously used, or are you talking about the minecraft computer autostarting the program you've being working on ?

(I do use Notepad++) But what I mean is like doing

file = fs.open("state", "w")
file.writeLine("Test")

But I really don't know how I could save the variable (OP) in a different file.
sjele #6
Posted 07 September 2012 - 01:42 PM

file = fs.open("state", "w")  --Opens the file state in writing mode
file.writeLine(OP) --Writes the var OP in the file state
file.close --Just incase