Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This script is [Work in progress], and will not function as title says just about yet --
- -- Script created by Frekvens1, however, most songs within the script are not --
- -- OpenRadio version: Alpha 1.0.0 --
- -- Check out my Github! 'https://github.com/Frekvens1/OpenComputers'
- -- OpenComputers Mod for Minecraft, usi+ng Lua 5.2 --
- -- pastebin get qq9CcAg2 openRadio.lua --
- --[START] local variables used to perform tasks within the OpenComputers mod --
- local component = require("component")
- local term = require("term")
- local fs = require("filesystem")
- local shell = require("shell")
- local inb = component.iron_noteblock.playNote
- --[END] local variables used to perform tasks within the OpenComputers mod --
- --[START] Music player, using iron note block --
- function playSong(song)
- local noteCount = 0
- local maxLayers = song.layers
- maxLayers = maxLayers + 1
- local name = song.name
- if not (name == "nil") then
- term.clear()
- print("Playing: "..name)
- end
- while noteCount < song.n_total do
- os.sleep(song.speed)
- local layerCount = 0
- while layerCount < maxLayers do
- local variable = song["note_"..noteCount.."_"..layerCount]
- --print("String name: ".."note_"..noteCount.."_"..layerCount)
- if (variable == "nil") then
- elseif (variable == nil) then
- else
- local inst
- local note
- for count, i in ipairs(variable) do
- if count == 1 then
- inst = i
- elseif count == 2 then
- note = i
- end
- end
- if (note == "nil") then
- elseif (inst == "nil") then
- else
- local fixInst
- if (inst==0) then
- fixInst = 0
- elseif (inst==1) then
- fixInst = 4
- elseif (inst==2) then
- fixInst = 1
- elseif (inst==3) then
- fixInst = 2
- elseif (inst==4) then
- fixInst = 3
- end
- inb(tonumber(fixInst), tonumber(note))
- end
- end
- layerCount = layerCount + 1
- end
- noteCount = noteCount + 1
- end
- end
- --[END] Music player, using iron note block --
- --playSong(he_s_a_pirate)
- local myRadioSongs = {}
- local files, reason = fs.list("songs")
- if files then
- local i = 1
- for mySong in files do
- if not (mySong == "nil") then
- if (string.find(mySong, "_openradio.lua")) then
- myRadioSongs[tonumber(i)] = mySong
- i = i + 1
- end
- end
- end
- end
- local args, options = shell.parse(...)
- if (args[1] == nil) then
- for i, mySong in ipairs(myRadioSongs) do
- print(i..": "..mySong)
- end
- print("")
- print("Arguments:")
- print("openRadio {song as index}, openRadio list, openRadio random, openRadio loop")
- elseif args[1] == "list" then
- print("Will now play songs in order")
- elseif args[1] == "random" then
- print("Will now play something random")
- elseif args[1] == "loop" then
- print("Will now loop the songs")
- else
- local path = "songs/"..myRadioSongs[tonumber(args[1])]
- local path_lenght = string.len(path)
- local fixedPath = path:sub(1,path_lenght - 4)
- print(fixedPath)
- playSong(require(fixedPath))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement