Posted 01 March 2014 - 02:19 AM
i had written a program to controll 2 radios from open blocks, and it worked fine, then i discovered the terminal glasses from open peripherals, and decided to impliment them into the radio program so i could controll them from anywhere near my base. now i am having trouble with it. it runs fine once if i use station 1, but if i try any of the others, or try to run it agian, it just stops working. no error, just non responsive.i would like it to be possible to be activate agian when it finishes, so i can use it agian when i want. im getting pretty burnt out here, so i would greatly appreciate some help.
here are the codes.
the semi-working updated code:
here are the codes.
the semi-working updated code:
local bridge = peripheral.wrap("top")
while true do
local event, destination = os.pullEvent("chat_command")
if destination == "radio" then
bridge.clear()
bridge.addText(6, 6, "You are now in the Radio Channel")
bridge.addText(6, 15, "Please select a station: Station1, Station2, Off")
local event, station = os.pullEvent("chat_command")
if station == "Station1" then
bridge.clear()
bridge.addText(6, 6, "Please Select a Volume: 1-15")
local event, volIn = os.pullEvent("chat_command")
local volOut = tonumber(volIn)
redstone.setOutput("back", false)
redstone.setOutput("bottom", false)
redstone.setAnalogOutput("back", volOut)
bridge.clear()
bridge.addText(6, 6, "You are Listening to")
bridge.addText(6, 15, "Station1 Radio,")
bridge.addText(6, 24, "Enjoy!")
sleep(15)
bridge.clear()
end
end
local event, station = os.pullEvent("chat_command")
if station == "Station2" then
bridge.clear()
bridge.addText(6, 6, "Please Select a Volume: 1-15")
local event, volIn = os.pullEvent("chat_command")
local volOut = tonumber(volIn)
redstone.setOutput("back", false)
redstone.setOutput("bottom", false)
redstone.setAnalogOutput("bottom", volIn)
bridge.clear()
bridge.addText(6, 6, "You are Listening to")
bridge.addText(6, 15, "Station2,")
bridge.addText(6, 24, "Enjoy!")
sleep(15)
bridge.clear()
end
end
local event, station = os.pullEvent("chat_command")
if station == "Off" then
bridge.clear()
bridge.addText(6, 6, "Radio Shutting Off")
redstone.setOutput("back", false)
redstone.setOutput("bottom", false)
sleep(10)
bridge.clear()
bridge.addText(6, 6, "Radio Off")
sleep(5)
bridge.clear()
end
and the working original:
local function use()
print("Stations")
print("Station1")
print("station2")
end
local tArgs = { ... }
if tArgs[1] == nul then
print("Usage: <Station> <Volume>")
print("Stations: Off, Station1, station2")
print("Volume: 0-15")
end
local tArgs = { ... }
if tArgs[1] == "Off" then
redstone.setOutput("back", false)
redstone.setOutput("bottom", false)
print(" Shutting Off")
print("Bye!")
end
local tArgs = { ... }
local vol = tonumber(tArgs[2])
if tArgs[1] == "Station1" then
redstone.setOutput("back", false)
redstone.setOutput("bottom", false)
redstone.setAnalogOutput("bottom", vol)
print("You are Listening to")
print("Station1 ")
print("Enjoy!")
end
local tArgs = { ... }
local vol = tonumber(tArgs[2])
if tArgs[1] == "station2" then
redstone.setOutput("back", false)
redstone.setOutput("bottom", false)
redstone.setAnalogOutput("back", vol)
print("You are Listening to")
print("station2")
print("Enjoy!")
end
thanks!