Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- verze = "20.1224.R1"
- local speaker = nil
- local tArgs = { ... }
- local n = 0
- local s = 0
- local nastroj = {}
- nastroje = {
- [1] = "harp",
- [2] = "bass",
- [3] = "basedrum",
- [4] = "bell",
- [5] = "chime",
- [6] = "flute",
- [7] = "hat",
- [8] = "snare",
- [9] = "xylophone",
- }
- local function load(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- if fs.exists("/C/system/RAM/devices/speaker.tmp") then
- speakers = {}
- speakers = load("/C/system/RAM/devices/speaker.tmp")
- speaker = peripheral.wrap(tostring(speakers[0]))
- if speaker == nil then speaker = peripheral.wrap(tostring(speakers[1])) end
- else
- speaker = peripheral.find("speaker")
- end
- function p(note,s,nas)
- if note > 1 then speaker.playNote(nastroje[nas],1,note) end
- sleep(0.15*s)
- end
- function play (soubor)
- if fs.exists(soubor) then
- file = fs.open(soubor, "r")
- if file then
- i = 0
- while file.readLine() do
- i = i + 1
- end
- file.close()
- end
- file = fs.open(soubor, "r")
- for q=1, i do
- radek = file.readLine()
- n = tonumber(string.sub(radek,1,2))
- s = tonumber(string.sub(radek,4,6))
- nastroj = tonumber(string.sub(radek,8,8))
- hlasitost = tonumber(string.sub(radek,10,10))
- p(n,s, nastroj)
- end
- file.close()
- end
- end
- if #tArgs > 0 then
- play(tArgs[1])
- else
- play(shell.dir().."/nahravka.txt")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement