Posted 10 September 2016 - 06:53 AM
Hey everybody I have been banging my head against my keyboard and so far nothan is working as planned. So what I have been trying to do is simply make a script that toggles a Bundled cable that connects to about 9 different colors that connect to Wireless Transmitters that connect to Lamps. My problem is I can't find a script that works even when I make/modify my own or others scripts.
I know there are different ways other then using a computer to toggle the lights but I like to Program and to have everything setup this way.
If anyone could help me by making a toggle script that can work with either one or more colors at a time that would be awesome.
Also what I'm trying to do is control this buildings lights that is about 200m away from my home and this would be on the Server computer, I would be accessing this program via Wireless Modem from my Client.
If you have any questions let me know. I'm tired and i'm going to bed :P/>/>
I know there are different ways other then using a computer to toggle the lights but I like to Program and to have everything setup this way.
If anyone could help me by making a toggle script that can work with either one or more colors at a time that would be awesome.
Also what I'm trying to do is control this buildings lights that is about 200m away from my home and this would be on the Server computer, I would be accessing this program via Wireless Modem from my Client.
If you have any questions let me know. I'm tired and i'm going to bed :P/>/>
Spoiler
local function menu(...)
term.clear()
term.setCursorPos(1,1)
printC("Server Building Light System Interface")
term.setCursorPos(1,19)
printC("Use the Arrow Keys to Navigate, Enter to Accept.")
term.setCursorPos(10,4)
local sel = 1
local list = {...}
local offX,offY = term.getCursorPos()
local curX,curY = term.getCursorPos()
while true do
if sel > #list then sel = 1 end
if sel < 1 then sel = #list end
for i = 1,#list do
term.setCursorPos(offX,offY+i-1)
if sel == i then
print("["..list[i].."]") --[[ The characters between the quotation marks are the characters used to show which option is active ]]--
else
print(" "..list[i].." ")
end
end
while true do
local e,e1,e2,e3,e4,e5 = os.pullEvent() --[[ Pulls the event for when a key is pressed ]]--
if e == "key" then
if e1 == 200 then --[[ This detects when the up arrow is pressed, it will then move one up. If you click it when you have the first option active, it will return to the bottom ]]--
sel = sel-1
break
end
if e1 == 208 then --[[ This detects when the down arrow is pressed, it will then move one down. If you click it when you have the last option active, it will return to the top ]]--
sel = sel+1
break
end
if e1 == 28 then --[[ This is when the enter key is pressed. It returns which ever option in the selection is active ]]--
term.setCursorPos(curX,curY)
return list[sel],sel
end
end
end
end
end
function Toggle_All() --[[ Option1, Option2, Option3 are the functions for each option in the menu. You don't have to do this, I just do it because it looks cleaner. ]]--
-- I was trying something like this
rs.setBundledOutput("bottom", colors.pink)
sleep(1)
end
function Toggle_Pink()
sleep(3)
end
function Toggle_Lime()
end
function Toggle_Orange()
term.setCursorPos(1,6)
print("You have selected option 2!")
sleep(3)
end
function Toggle_Brown()
term.setCursorPos(1,6)
print("You have selected option 3!")
sleep(3)
end
function Toggle_Red()
term.setCursorPos(1,6)
print("You have selected option 2!")
sleep(3)
end
function Toggle_Blue()
term.setCursorPos(1,6)
print("You have selected option 3!")
sleep(3)
end
function Toggle_Purple()
term.setCursorPos(1,6)
print("You have selected option 2!")
sleep(3)
end
function Toggle_Grey()
term.setCursorPos(1,6)
print("You have selected option 3!")
sleep(3)
end
function Toggle_Black()
term.setCursorPos(1,6)
print("You have selected option 2!")
sleep(3)
end
function Toggle_Cyan()
term.setCursorPos(1,6)
print("You have selected option 3!")
sleep(3)
end
while true do
local selection = menu( --[[ This is what is displayed on the screen. Separate each with a comma ]]--
"Toggle All",
"Toggle Pink",
"Toggle Lime",
"Toggle Orange",
"Toggle Brown",
"Toggle Red",
"Toggle Blue",
"Toggle Purple",
"Toggle Grey",
"Toggle Black",
"Toggle Cyan")
if selection == "Toggle All" then --[[ If the selected option is this one after clicking enter it would call Option1 function. and so on... ]]--
Toggle_All()
elseif selection == "Toggle Pink" then
Toggle_Pink()
elseif selection == "Toggle Lime" then
Toggle_Lime()
elseif selection == "Toggle Orange" then
Toggle_Orange()
elseif selection == "Toggle Brown" then
Toggle_Brown()
elseif selection == "Toggle Red" then
Toggle_Red()
elseif selection == "Toggle Blue" then
Toggle_Blue()
elseif selection == "Toggle Purple" then
Toggle_Purple()
elseif selection == "Toggle Grey" then
Toggle_Grey()
elseif selection == "Toggle Black" then
Toggle_Black()
elseif selection == "Toggle Cyan" then
Toggle_Cyan()
end
end
Edited on 11 September 2016 - 03:50 AM