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

What do you mean "61: ')' expected"? That line already has one!

Started by ZippoMoon, 16 January 2016 - 09:37 PM
ZippoMoon #1
Posted 16 January 2016 - 10:37 PM
If anyone can help me I'd appreciate it. Edit: Full line Reads as: bios. lua:14: [string "test"]:61: ')' expected
http://pastebin.com/B655dD0K
Edited on 16 January 2016 - 09:39 PM
Dragon53535 #2
Posted 16 January 2016 - 10:44 PM

print("Vault Door Lock: - [1] "VDL)
--# Should be
print("Vault Door Lock: - [1]"..tostring(VDL))
--#You need to combine them. Use .. to combine strings.
Also, same for the OTHER lines that are going to error as well.
Also, you probably want to fix your redstone controls, each button will only turn on a single color, never turn off, and every other color will also turn off.

Since rs.setBundledOutput sets every color at the same time, and only at the same time, you need to add and subtract the colors before turning them on. Those that are there, are turned on, those that aren't are turned off.


rs.setBundledOutput(side,colors.test(rs.getBundledInput(side),colors.white) and colors.subtract(rs.getBundledInput(side),colors.white) or colors.combine(rs.getBundledInput(side),colors.white))
That line will work for each of your colors. A little walkthrough:

Ternary statements:

Written in other languages as

(contintional) ? true : false
Which is, if the conditional is true (In our case, colors.test) it goes to the spot where true is, if it isn't, goes to false. It's just a simple if statement really, however in one line, and for setting values.
Lua doesn't really have ternary statements, but allows for them through the usage of and's and or's

(conditional) and true or false
Which is what i'm doing up there.

if (colors.test(rs.getBundledInput(side),colors.white) ) then
  colors.subtract(rs.getBundledInput(side),colors.white)
else
  colors.combine(rs.getBundledInput(side),colors.white)
end
And then it uses the result of this bit, to decide which colors to set.

As for your logout, use the error() function.
Edited on 16 January 2016 - 09:55 PM
ZippoMoon #3
Posted 16 January 2016 - 11:08 PM
OK, I've add the dots but now it's saying: test:9: attempt to index ? (a nil value)

Also @Dragon53535 what did you mean by "use the error() function"? I can only find one reference to error() on the wiki's function tutorial page.
KingofGamesYami #4
Posted 16 January 2016 - 11:16 PM
http://www.lua.org/pil/8.3.html
Dragon53535 #5
Posted 16 January 2016 - 11:26 PM
There exists no function called testBundledInput, what you want to do is

colors.test(rs.getBundledInput(side),colors.white)
I stand corrected. I've not used it before, nor seen it. Thanks BB
Also, it's colors (or colours) not color. It's always plural.

Always remember this: Computercraft uses Lua, which is an already made language that is used in many places. If something seems computercraft specific, it probably is, but if it's something like print or error or whatever, try Lua.org
Edited on 16 January 2016 - 10:32 PM
Bomb Bloke #6
Posted 16 January 2016 - 11:29 PM
If anyone can help me I'd appreciate it. Edit: Full line Reads as: bios. lua:14: [string "test"]:61: ')' expected

When you get an error along these lines, remember that it's not so much complaining that the line doesn't have whatever it's expecting, it's more complaining that before it gets to the expected symbol it's finding something that SHOULDN'T be there. In this case, you stuck a variable name directly after a string, with none of the symbols that could be used to join / divide them.

There exists no function called testBundledInput, what you want to do is

Eh what? He's not even getting an "attempt to call nil" error. It's complaining that he's trying to treat "color" as a table, and "color" is nil. All he needs to do is switch it to "colors".
ZippoMoon #7
Posted 16 January 2016 - 11:31 PM
I don't follow, if there's no function called testBundledInput then what's this: http://computercraft...estBundledInput

Edit: ninja'd

OK, first off thanks to everyone who helped so far, how ever I have a new error that it throw's out after I input the password: test:62: attempt to concatenate string and boolean
Edited on 16 January 2016 - 10:45 PM
Lyqyd #8
Posted 16 January 2016 - 11:45 PM
If you've got another error after changing the code, be sure to post the updated code.
ZippoMoon #9
Posted 16 January 2016 - 11:49 PM
If you've got another error after changing the code, be sure to post the updated code.
I did, the URL is the same as up above.
Dragon53535 #10
Posted 16 January 2016 - 11:50 PM

print("Vault Door Lock: - [1] "..VDL)
--# Should be
print("Vault Door Lock: - [1]"..tostring(VDL))
--#You need to tostring the boolean
I suppose taking the meaning of the above post is good, but you really should of gone with the entirety of what i put :P/>
Edited on 16 January 2016 - 10:51 PM
ZippoMoon #11
Posted 16 January 2016 - 11:54 PM

print("Vault Door Lock: - [1] "..VDL)
--# Should be
print("Vault Door Lock: - [1]"..tostring(VDL))
--#You need to tostring the boolean
I suppose taking the meaning of the above post is good, but you really should of gone with the entirety of what i put :P/>
Wait, you literally need to add in tostring to the code for it to work? I thought that to illustrate the point!
Dragon53535 #12
Posted 16 January 2016 - 11:59 PM
Yes, you can't usually combine a non string and a string and expect it to work. Lua allows it usually for numbers (not bools) however many other languages explicitly require it to be a string.
Ajt86 #13
Posted 16 January 2016 - 11:59 PM

print("Vault Door Lock: - [1] "..VDL)
--# Should be
print("Vault Door Lock: - [1]"..tostring(VDL))
--#You need to tostring the boolean
I suppose taking the meaning of the above post is good, but you really should of gone with the entirety of what i put :P/>
Wait, you literally need to add in tostring to the code for it to work? I thought that to illustrate the point!

You need to add tostring if it's not a string otherwise you'll get an error about concatenating string and insert type here
ZippoMoon #14
Posted 17 January 2016 - 12:02 AM
Thanks again everyone, for now I'm going to read that link Yami gave.