#1
Posted 01 November 2012 - 12:57 AM
Thing is, I can only figure out how to clear them -all,- so it'd shut things down.
Is there any special way to do this?
Additional information, in case it helps. I plan to put this all inside a 'while true do' loop that will run until the user inputs a quit command.
#2
Posted 01 November 2012 - 01:16 AM
local sides = rs.getSides() -- this gets all of the sides available, easier than making a table with the sides in them for _, side in pairs(sides) do rs.setOutput(side, false) end
#3
Posted 01 November 2012 - 01:55 AM
#4
Posted 01 November 2012 - 02:01 AM
local yourSide = 'back' -- or whatever side rs.setOutput(yourSide, not rs.getOutput(yourSide))
#5
Posted 01 November 2012 - 05:04 PM
#6
Posted 01 November 2012 - 05:07 PM
It was like...right there.
#7
Posted 01 November 2012 - 05:25 PM
function setBundledColor(side, color, state)
if state then
if not colors.test(rs.getBundledOutput(side), color) then
rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side), color))
end
else
if colors.test(rs.getBundledOutput(side), color) then
rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side), color))
end
end
end
#8
Posted 01 November 2012 - 05:30 PM
#9
Posted 01 November 2012 - 05:31 PM
setBundledColor("back", colors.green, true)
Just like with the plain redstone functions, only you specify the color as well.
#10
Posted 01 November 2012 - 05:37 PM
#11
Posted 01 November 2012 - 05:39 PM
#12
Posted 01 November 2012 - 05:44 PM
#13
Posted 01 November 2012 - 06:10 PM
#14
Posted 01 November 2012 - 10:59 PM
The way I'd do it is to just have two true/false variables to track the red and green colors, and set the rs bundled outputs accordingly. This script makes it so that the R key toggles red and the G key toggles green, just as an example.
local red = false
local green = false
while true do
local _, key = os.pullEvent('key')
-- toggle our variables on the keys pressed
if key == keys.r then
red = not red
elseif key == keys.g then
green = not green
end
-- add the colors to the sum of the rs output if they are on
local sum = 0
if green then sum = sum + colors.green end
if red then sum = sum + colors.red end
-- set the output
rs.setBundledOutput('back', sum)
end
#15
Posted 02 November 2012 - 03:28 AM
Tassyr, on 01 November 2012 - 06:10 PM, said:
I've got a snippet of code elsewhere on the forums that toggles the state of a specific color on a specific side, if that's what you're looking for. I believe it's around page six of my post history, or I can find it for you this evening.
#16
Posted 02 November 2012 - 09:56 AM
Lyqyd, on 02 November 2012 - 03:28 AM, said:
Tassyr, on 01 November 2012 - 06:10 PM, said:
I've got a snippet of code elsewhere on the forums that toggles the state of a specific color on a specific side, if that's what you're looking for. I believe it's around page six of my post history, or I can find it for you this evening.
Right, I don't really know how to access your history- I'm new to this forum -and- lua. XD could I beg you to repost it here?
#17
Posted 02 November 2012 - 12:53 PM
function toggleBundledColor(side, color)
rs.setBundledOutput(side, (colors.test(rs.getBundledOutput(side), color) and colors.subtract(rs.getBundledOutput(side), color) or colors.combine(rs.getBundledOutput(side), color)))
end
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











