Posted 21 February 2012 - 07:16 AM
the issue is the code works great except one hitch i can not find a way around when i toggle lets say bridge … i am unable to also toggle exterior lights at the same time but i can do them one at a time i have figured out that the computer is outputing properly via some debugging but its not activating more then one color at a time on the bundled cable i have a feeling im handling rs.setBundledOutput in a limiting way or not properly
the computer is setup to listen on a constant loop until another computer sends a matching string ex bridge and so on
test it out if you wish i just cant get it to work and would love a solution i know im on the right track
——————————————————–
the computer is setup to listen on a constant loop until another computer sends a matching string ex bridge and so on
test it out if you wish i just cant get it to work and would love a solution i know im on the right track
Spoiler
term.clear()
term.setCursorPos(1,1)
res = 0
direc = 0
tcolor = 0
ncolor = 0
--print("variables past")
rednet.open("right")
rednet.open("left")
function timedon()
term.setCursorPos(2,2)
rs.setBundledOutput(direc, colors.combine(ncolor))
print(res.." Toggled on")
end
function timedoff()
term.setCursorPos(2,2)
rs.setBundledOutput(direc, colors.subtract(tcolor, ncolor))
print(res.." Toggled off")
end
function control()
if rs.getBundledInput(direc, tcolor) == tcolor then
rs.setBundledOutput(direc, colors.subtract( tcolor, ncolor ))
print(res.." toggled off")
tcolor, ncolor, res, direc = 0
elseif rs.getBundledInput(direc, tcolor) == 0 then
rs.setBundledOutput("back", ncolor)
print(res.." toggled on")
tcolor, noclor, res, direct = 0
end
end
while true do
term.clear()
term.setCursorPos(1,1)
time = os.time()
print("Current time is: "..textutils.formatTime( os.time(), false ).."...")
print(tcolor)
print(ncolor)
print(direc)
print(res)
term.setCursorPos(1,17)
print("rawtime: "..os.time())
term.setCursorPos(1,12)
--print("pullstart")
-- ***********Pauses here *****************
id, com = rednet.receive(5)
--print("pullend")
sleep(0)
if math.floor(time) == 6 then
direc = "top"
tcolor = 1
ncolor = 1
res = "interior lights"
term.setCursorPos(2,6)
timedoff()
elseif math.floor(time) == 17 then
direc = "top"
tcolor = 1
ncolor = 1
term.setCursorPos(2,6)
res = "interior lights"
timedon()
elseif math.floor(time) == 5 then
direc = "top"
tcolor = 16384
ncolor = 16384
res = "SkyLight"
term.setCursorPos(2,6)
timedon()
elseif math.floor(time) == 18 then
direc = "top"
tcolor = 16384
ncolor = 16384
res = "SkyLight"
term.setCursorPos(2,6)
timedoff()
elseif com == "front door" then
res = "front door"
direc = "back"
tcolor = 16384
ncolor = 16384
term.setCursorPos(1,12)
print("done")
control()
elseif com == "back door" then
res = "back door"
direc = "back"
tcolor = 1
ncolor = 1
term.setCursorPos(1,12)
print("done")
control()
elseif com == "exterior lights" then
res = "exterior lights"
direc = "back"
tcolor = 2
ncolor = 2
term.setCursorPos(1,12)
print("done")
control()
elseif com == "bridge" then
res = "bridge"
direc = "back"
tcolor = 2048
ncolor = 2048
term.setCursorPos(1,12)
print("done")
control()
--elseif com == "door front" then
--term.setCursorPos(1,12)
--Print("opening front door")
-- or test == false then
-- rs.setBundledOutput("back", colors.combine( colors.red ))
-- or test == true then
-- rs.setBundledOutput("back", colors.subtract( colors.red))
end
term.setCursorPos(1,1)
end
——————————————————–