Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- line = 1
- song = {...}
- run = true
- instr = 0
- notenum = 0
- notes = {}
- instrs = {}
- run = true
- waits = {}
- if song[1] == nil then
- print("Please specify file to save to")
- run = false
- end
- if run == true then
- fileto = song[1]
- print("Saving File at: " .. song[1] .. " ok? y or yes ")
- ok = read()
- if ok == "y" or ok == "yes" then
- run = true
- else
- print("Chose to not save file at " .. song[1] .. "")
- run = false
- end
- end
- side = "bottom"
- inb = peripheral.wrap(side)
- function savefile()
- i = 0
- file = fs.open(fileto, "w")
- for i = 1, notenum do
- if notes[i] then
- sleep(0.05)
- file.write(instrs[i] .. "\n" )
- file.write(notes[i] .. "\n" )
- file.write(waits[i] .. "\n" )
- end
- end
- file.close()
- print("saved song!")
- end
- function noteup()
- if instr ~= 4 then
- instr = instr +1
- else
- instr = 0
- end
- end
- function notedown()
- if instr ~= 0 then
- instr = instr -1
- else
- instr = 4
- end
- end
- while run == true do
- term.clear()
- term.setCursorPos(1,1)
- print("Instrument: " .. instr .. " ")
- if notes[notenumm] then
- print("Last note: " .. notes[notenumm] .. " ")
- end
- time1 = os.clock()
- event, num = os.pullEvent("key")
- if num == 200 or num == 17 then
- noteup()
- end
- if num == 208 or num == 31 then
- notedown()
- end
- if num == 2 or num == 3 or num == 4 or num == 5 or num == 6 or num == 7 or num == 8 or num == 9 or num == 10 or num == 11 then
- time2 = os.clock()
- time = time2 - time1
- note = num -1
- note = note *2
- note = note +4
- notes[notenum] = note
- notenumm = notenum
- instrs[notenum] = instr
- waits[notenum] = time
- inb.playNote(instr,note)
- notenum = notenum +1
- line = line +3
- elseif num ~= 208 and num ~= 31 and num ~= 200 and num ~=17 then
- run = false
- quit = true
- end
- end
- if quit == true then
- savefile()
- end
Advertisement
Add Comment
Please, Sign In to add comment