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

shutting down mashines.... I'm confused

Started by Hocico, 19 September 2016 - 07:20 PM
Hocico #1
Posted 19 September 2016 - 09:20 PM
Hey guys!

Sory for asking this (maybe) very easy question, but I'm looking for an aswer since hours. :wacko:/>

On my server I had build 16 BIG REACTORS. And I want to write a program to start them one after annother.

so far so clear, the command is: rs.setBudledOutput("back", colors.black)
[or any other color]

but….. whats the command to shut them down with annother program? like "reactor_on" and "reactor_off"

I tried several commands (for example rs.setBudledOutput("back", colors.black, true) to start the reactor and rs.setBudledOutput("back", colors.black, false) to shut it down)

The point is: nothing happened when I activate the "reactor_off" program. the reactor is still active.

Ctrl + T is not an option, is it? It would be nice if the reactors are shutting down one after annother AND whireless ;)/>

Can someone help me out?

P.S.: if a thread for things like this already exist, please don't flame me :(/> I'm realy confused. (sory)
Lyqyd #2
Posted 20 September 2016 - 02:18 AM
The bundled color functions take a number, and the colors.black and similar shortcuts are easy programmer-friendly ways to reference the correct numbers. Just use 0 to turn off all of the colors:


rs.setBundledOutput("back", 0)
TheRockettek #3
Posted 20 September 2016 - 07:54 AM
what you could do is put a wired modem on all the computer ports (you may need to make them) then connect them all together with wire, if its in the network you can do like

peripheral.wrap("reactor_5")

to get the name of the reactor, it will show in chat once you connect it

"reactor_9001 connected to the network"

or you could run the peripheral program in shell (theres a function but i havent played cc in over 3 weeks D:)
Hocico #4
Posted 20 September 2016 - 10:28 AM
The bundled color functions take a number, and the colors.black and similar shortcuts are easy programmer-friendly ways to reference the correct numbers. Just use 0 to turn off all of the colors:


rs.setBundledOutput("back", 0)

That's the code to shut all down at once. But whats the code to shut them down one after annother?

something like… a counter-command for

rs.setBundledOutput("back", colors.white + colors.orange + colors.magenta)
sleep(5)
rs.setBundledOutput("back", colors.white + colors.orange + colors.magenta + colors.lightBlue)
sleep(5)
rs.setBundledOutput("back", colors.white + colors.orange + colors.magenta + colors.lightBlue + [.....])

nonetheless: thanks so far ;-)
Bomb Bloke #5
Posted 20 September 2016 - 12:29 PM
what you could do is put a wired modem on all the computer ports (you may need to make them) then connect them all together with wire, if its in the network you can do like…

To be clear, Rockettek's trying to point out here that you can build Computer Ports into your rector instead of the Redstone Ports you're presumably using now. This'd give you peripheral functionality.

That's the code to shut all down at once. But whats the code to shut them down one after annother?

Think of a bundled cable as having a single sixteen-bit number attached to it - the bits required to represent that number link the the coloured cables you've got active. For example, if you're outputting the number 2560, then the binary representation of 0000 1010 0000 0000 tells us that blue (0000 1000 0000 0000) and cyan (0000 0010 0000 0000) are enabled, but all the other colours are disabled.

So say you wanted to disable the blue wire while leaving cyan enabled… you'd simply set blue's bit (value of 2048) to 0, leaving a new output value of just 512. The colours API has functions for this purpose built in - "combine" and "subtract".

Eg, you might do something like:

local function toggleColour(colour)
	if colours.test(rs.getBundledOutput("back"), colour) then
		-- Colour already on, disable it:
		rs.setBundledOutput("back", colours.subtract(rs.getBundledOutput("back"), colour)
	else
		-- Colour not currently on, enable it:
		rs.setBundledOutput("back", colours.combine(rs.getBundledOutput("back"), colour)
	end
	
	-- Return true/false depending on whether the wire is now on or off:
	return colours.test(rs.getBundledOutput("back"), colour)
end
TheRockettek #6
Posted 20 September 2016 - 03:26 PM
Anotger advantage of using comphter ports is that you can get data from the reactprs like how full they are, how much they are making .etc

You can use this to like make a program that auto turns them all of if their buffers are full
Hocico #7
Posted 23 September 2016 - 07:56 PM
hey cool thanks guys it seems to work^^

I'll try the BC-blck later. but thanks anyway ;-)