Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local side = "top"
- if not args[1] then
- local str = "OFF"
- local vol = redstone.getAnalogOutput(side)
- if vol ~= 0 then str = "ON" end
- print("Radio is currently "..str..".")
- print("Volume is "..vol.." / 15.")
- print("\n")
- print("Usage: radio < on / off / volume >")
- print("Volume can be an integer from 1 to 15. Use 0 to turn off the radio.")
- return
- end
- if args[1] == "on" then
- if redstone.getAnalogOutput(side) ~= 0 then
- print("The radio is already on.")
- end
- io.write("What volume? (1 - 15): ")
- local vol = io.read()
- os.run({}, shell.getRunningProgram(), vol)
- return
- elseif args[1] == "off" then
- redstone.setAnalogOutput(side,0)
- print("Turning radio off. Goodbye!")
- return
- else
- local vol = tonumber(args[1])
- if not vol or vol ~= math.floor(vol) then
- print("Please provide an integer.")
- return
- end
- vol = math.floor(vol)
- if vol < 1 then
- os.run({}, shell.getRunningProgram(), "off")
- return
- end
- if vol > 15 then
- print("Volume is out of range. Please provide an integer below 16.")
- return
- end
- print("Setting volume to "..vol.." / 15.")
- redstone.setAnalogOutput(side, vol)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement