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

Question from extremely old topic.

Started by gjalt14, 23 January 2014 - 01:01 PM
gjalt14 #1
Posted 23 January 2014 - 02:01 PM
i got a simple thing but it isnt worrking program code:
print("welcome wait for the door to open")
sleep(2)
("redset right true")
sleep(2)
("redset right false")
("shutdown")
and if I run the program I get a bios error:
bios:399: [string "startup"]:3: ambiguous syntax
(function call x new statement)
Lyqyd #2
Posted 23 January 2014 - 02:25 PM
Don't post completely unrelated questions in ancient topics, please. I've split this for you.

I'm not sure what magic you think parentheses and quotes around a string are supposed to perform, but if you want to run a program, you need to use shell.run. You can fix this code by putting shell.run at the start of those three lines, so they look like:


shell.run("shutdown")
surferpup #3
Posted 24 January 2014 - 12:08 AM
Specifically (although there are far better ways to do this), your program would be syntactically correct if it read:


print("welcome wait for the door to open")
os.sleep(2)
shell.run("redset right true")
sleep(2)
shell.run("redset right false")
shell.run("shutdown")

Lua expects a function when you wrote just ("redset right true"). When it saw your parentheses ( ), it assumed you had tried to run a function, it just didn't know which one. What you gave it was the arguments to an unnamed, undeclared function. So it got confused.