
Untitled
By: a guest on Feb 19th, 2012 | syntax:
Lua | size: 1.49 KB | hits: 17 | expires: Never
pcall(magic.enable)
-- load song into table
args = { ... }
notes = {}
file = io.open(args[1], "r")
x = 1
while true do
note = file:read()
if note == nil then break end
table.insert(notes,note)
end
tempo = string.sub(notes[1], 2)
tempo = tempo / 100
tempo = .2 - tempo
currentoctave = 0
currentnote = 0
currentinstrument = 0
px,py,pz = magic.getPlayerLoc()
for x = 2, #notes do
if notes[x] == "BG" then currentinstrument = 4
elseif notes[x] == "CS" then currentinstrument = 3
elseif notes[x] == "SD" then currentinstrument = 2
elseif notes[x] == "BD" then currentinstrument = 1
elseif notes[x] == "PI" then currentinstrument = 0
elseif notes[x] == "1" then currentoctave = 0
elseif notes[x] == "2" then currentoctave = 1
elseif notes[x] == "3" then currentoctave = 2
elseif notes[x] == "." then sleep(tempo)
else
if notes[x] == "F#" then currentnote = 0 end
if notes[x] == "G" then currentnote = 1 end
if notes[x] == "G#" then currentnote = 2 end
if notes[x] == "A" then currentnote = 3 end
if notes[x] == "A#" then currentnote = 4 end
if notes[x] == "B" then currentnote = 5 end
if notes[x] == "C" then currentnote = 6 end
if notes[x] == "C#" then currentnote = 7 end
if notes[x] == "D" then currentnote = 8 end
if notes[x] == "D#" then currentnote = 9 end
if notes[x] == "E" then currentnote = 10 end
if notes[x] == "F" then currentnote = 11 end
currentnote = currentnote + (currentoctave * 12)
magic.playSound(px,py,pz,currentinstrument,currentnote, true)
end
end