This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Hellchild96's profile picture

= Expected Error

Started by Hellchild96, 01 July 2013 - 08:26 AM
Hellchild96 #1
Posted 01 July 2013 - 10:26 AM
I'm attempting to make a looping DJ program, so that everytime a redstone pulse reaches the computer, it plays the disk again.

This is my code:

local Loop = 1
Repeat
Repeat
os.sleep(1)
until redstone.getinput(Back)
shell.run("dj")
Loop = Loop + 1
Until Loop = 3
end

Whenever I attempt to run this, I get an error that says "bios:338: [string"music"]:3: '=' expected"
My understanding of this is that there is an = expected on line 3, but that's a repeat? Could somebody point me in the right direction here?

Btw, I'm a complete Lua noob, so use small words.
Lyqyd #2
Posted 01 July 2013 - 02:10 PM
Split into new topic.

Lua is case-sensitive, which means that "repeat" and "Repeat" are not the same thing. Make sure you use "repeat". You'll also need to use redstone.getInput("back"). Note the use of quotes, and all-lowercase "back".
Hellchild96 #3
Posted 01 July 2013 - 03:02 PM
Thanks for the help. You cleared up that issue no problem. My code now looks like this:

local Loop = 1
repeat
repeat
os.sleep(1)
until redstone.getinput("back")
shell.run("dj")
Loop = Loop + 1
Until Loop == 3

I'm now getting music:5: attempt to call nil . Does this mean that it doesn't recognize "back" as an actual thing, or am I just being a bit of a derp?
Kingdaro #4
Posted 01 July 2013 - 03:21 PM
Again, Lua is case sensitive. It should be "getInput" with a capital I, and "until", all lowercase.
Apfeldstrudel #5
Posted 01 July 2013 - 05:46 PM
Hehe, capitalization is derpy- here:

keywords:lowercase
functions: for example-seeFirstLetter,notCapitalized
Hellchild96 #6
Posted 02 July 2013 - 03:26 PM
Ok, I think I've got this capitalization thing down. My code now looks like this (Some alterations, same function)

local count = 1
repeat
while true do
local event, count = os.pullEvent("redstone")
if redstone.getInput("back) then
disk.playAudio
count = count + 1
else os.sleep(1)
end
until count == 3

I'm now getting this error:
bios:338: [string "music"]:7: '=' expected
I've tried this line with a;; combinations of capital lettering and =/== and nothing seems to fix it. Could you guys be so good as to work your magic again?
Kingdaro #7
Posted 02 July 2013 - 03:41 PM
Put () after disk.playAudio.


disk.playAudio()

Also, missing a quote on the line before that:


if redstone.getInput("back") then
CoderPuppy #8
Posted 02 July 2013 - 03:41 PM
On line 6 replace disk.playAudio with disk.playAudio(). When calling functions you need parentheses.

Edit: Ninjad!
Lyqyd #9
Posted 02 July 2013 - 04:55 PM
You also never provide a means to escape the inner loop, so the outer loop is unnecessary.