Jump to content




bundledcable input/output (V1.58)


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

#1 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 24 July 2014 - 12:59 AM

Hello everyone,

Im creating a script to control my 4 nuclear reactors.
I dont run into any errors but I cant turn more then 1 reactor online.

For example:
I turn Reactor 1 online, it goes online.
When I want reactor 2 online together with 1, it turns Reactor 2 online and 1 offline.
This also counts for all the 4 reactors.

When turning another reactor online it turns the one before offline.

I think the problem is in
   if rs.testBundledInput("bottom", colors.white) then
    rs.setBundledOutput("bottom", colours.black)

Each reactor has his own cable color of course.
Im using the black color to tell the reactor to go offline if online.
But it also does for all the other reactors.
Is there a way to avoid this?

Im running Computercraft 1.58

Posted Image

Posted Image

Posted Image

os.pullEvent = os.pullEventRaw
local width, height = term.getSize()

-- ######################
-- #### GUI
-- ######################

while true do
term.setCursorPos(1, 1)
term.setBackgroundColor(colors.lightBlue)
term.clear()
term.setTextColor(colors.black)
term.setBackgroundColor(colors.orange)
term.clearLine()

term.setCursorPos(1, height)
term.clearLine()
local text = "Nuclear Research Facility"
term.setCursorPos(math.floor((width - #text) / 2), 1)
term.write(text)

-- ######################
-- #### Reactor 1
-- ######################

term.setTextColor(colors.white)
term.setBackgroundColor(colors.gray)
term.setCursorPos(1, 2)
term.write("														  ")
term.setCursorPos(1, 3)
term.write("														  ")
   if rs.testBundledInput("bottom", colors.white) then
    rs.setBundledOutput("bottom", colours.black)
    term.setCursorPos(11, 9)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.gray)
term.write("	 Futo Maki Reactor 1	 ")
term.setCursorPos(11,10)
term.setTextColor(colors.red)
term.setBackgroundColor(colors.gray)
term.write("	    GOING OFFLINE	    ")
rs.setBundledOutput("bottom", colours.black)
sleep(3)
   shell.run("mainframe")
   else
   rs.setBundledOutput("bottom", colors.white)
    term.setCursorPos(11, 9)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.gray)
term.write("	 Futo Maki Reactor 1	 ")
term.setCursorPos(11,10)
term.setTextColor(colors.lime)
term.setBackgroundColor(colors.gray)
term.write("	    GOING ONLINE		 ")
sleep(3)
   shell.run("mainframe")
   end
end


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 24 July 2014 - 01:15 AM

Instead of:

rs.setBundledOutput("bottom", colours.black)

Use:

rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colours.black))

Check out the commands in the colors API.

Edited by Bomb Bloke, 24 July 2014 - 01:17 AM.


#3 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 24 July 2014 - 01:23 AM

View PostBomb Bloke, on 24 July 2014 - 01:15 AM, said:

Instead of:

rs.setBundledOutput("bottom", colours.black)

Use:

rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colours.black))

Check out the commands in the colors API.

Maybe I dont understand this but when using that line it still turns off the other reactors.

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 24 July 2014 - 01:43 AM

In that case, you may need to look where the black wire is leading to.

#5 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 24 July 2014 - 01:47 AM

View PostBomb Bloke, on 24 July 2014 - 01:43 AM, said:

In that case, you may need to look where the black wire is leading to.
The black wire goes nowhere.
Im using it to turn off the reactor that I want to turn off.
But I dont want the other reactors go off if they are on and thats what happening now.

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 24 July 2014 - 01:51 AM

This may be a silly question, but do you understand what the line I gave you does?

#7 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 24 July 2014 - 01:54 AM

View PostBomb Bloke, on 24 July 2014 - 01:51 AM, said:

This may be a silly question, but do you understand what the line I gave you does?
Yes I just found out.
I fixed it now and it works smoothly now.

Thank you

   if rs.testBundledInput("bottom", colors.yellow) then
rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colours.yellow))
	term.setCursorPos(11, 9)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.gray)
term.write("	 Futo Maki Reactor 4	 ")
term.setCursorPos(11,10)
term.setTextColor(colors.red)
term.setBackgroundColor(colors.gray)
term.write("		GOING OFFLINE		")
rs.setBundledOutput("bottom", colours.black)
sleep(3)
   shell.run("mainframe")
   else
rs.setBundledOutput("bottom", colors.combine(rs.getBundledOut put("bottom"), colours.yellow))
	term.setCursorPos(11, 9)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.gray)
term.write("	 Futo Maki Reactor 4	 ")
term.setCursorPos(11,10)
term.setTextColor(colors.lime)
term.setBackgroundColor(colors.gray)
term.write("		GOING ONLINE		 ")
sleep(3)
   shell.run("mainframe")
   end
end

Edited by Xixili, 24 July 2014 - 01:55 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users