Posted 19 October 2012 - 05:14 PM
I'm making a small note block song system, and I'm using this lua script to pulse a colored wire a certain number of times to tell another computer what note to play, but on my main control system for it - I have this odd error. Here's the code:
local monitor = peripheral.wrap("left")
term.redirect(monitor)
term.clear()
sleep(5)
local song = {}
local filename = fs.combine(disk.getMountPath("top"), "songdata")
local file = fs.open(filename, "r")
if disk.hasData("top") then
print("Reading song '"..disk.getLabel("top").."' . Commence song!")
for line in io.lines(file) do
table.insert(song, line)
end
end
term.restore()
else
print("No data in disk!")
term.restore()
end
for i = 1, #song do
clin = song[i]
local col
check = string.sub(clin, 1, 2)
if check == "^1" then
col = 1
elseif check == "^2" then
col = 2
elseif check == "^3" then
col = 4
elseif check == "^4" then
col = 8
elseif check == "^5" then
col = 16
end
local nt
notecheck = string.sub(clin, 4)
if notecheck = "1" then
nt = 1
elseif notecheck = "2" then
nt = 2
elseif notecheck = "3" then
nt = 3
elseif notecheck = "4" then
nt = 4
elseif notecheck = "5" then
nt = 5
elseif notecheck = "6" then
nt = 6
elseif notecheck = "7" then
nt = 7
elseif notecheck = "8" then
nt = 8
elseif notecheck = "9" then
nt = 9
elseif notecheck = "10" then
nt = 10
elseif notecheck = "11" then
nt = 11
elseif notecheck = "12" then
nt = 12
elseif notecheck = "13" then
nt = 13
elseif notecheck = "14" then
nt = 14
elseif notecheck = "15" then
nt = 15
elseif notecheck = "16" then
nt = 16
end
print(col.."|"..nt)
local times = nt
repeat rs.setBundledOutput('bottom', col) sleep() rs.setBundledOutput('bottom', 0) times = (times - 1) until times = 0
end