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

help needed by a simple Program

Started by fussel01, 06 October 2012 - 05:12 PM
fussel01 #1
Posted 06 October 2012 - 07:12 PM
Hello,
I tried to write my first little program itself. But I despair of the syntax. Perhaps mitr have someone help and show me my mistakes. Here's the code:


shell.run("clear")
a = 0
b = 0
setCursorPos(5,3)
print("Wieviel Weizen möchtest du holen ?\n\n")
write("Anzahl : ")
a = tonumber (read())
b = a + 0
shell.run("clear")
print("Bitte warten ....")
print("")
while a > 0 do
  rs.setBundledOutput("left", colors.grey)
  sleep(0.8)
  rs.setBundledOutput("left", colors.green)
  sleep(0.2)
  a = a - 1
end
shell.run("clear")
print("Die "..b" Weizen wurden abgeschickt ...")
print("")
print(" Das Programm wird nun gleich beendet !!!")
sleep(10)
shell.run("reboot")


Thanks in advance.
Sincerely yours
Fussel01
Kingdaro #2
Posted 06 October 2012 - 07:24 PM
I only found one mistake, with this line:

print("Die "..b" Weizen wurden abgeschickt ...")
There should be two more dots after the b. Think of the two dots as the glue that holds two strings together.
jag #3
Posted 06 October 2012 - 07:30 PM
At the bottom, instead of using shell.run("reboot") you could do os.reboot()
Kingdaro #4
Posted 06 October 2012 - 07:34 PM
What if he wants it to print "Goodbye"? XD
fussel01 #5
Posted 06 October 2012 - 07:39 PM
Thanks for the tips.
The two points I have included.
But I get the following error message:

: 4: Attempt to call NIL
CitricThunder #6
Posted 06 October 2012 - 07:49 PM
Thanks for the tips.
The two points I have included.
But I get the following error message:

: 4: Attempt to call NIL

Yeah you wrote setCursorPos when it should be term.setCursorPos
fussel01 #7
Posted 06 October 2012 - 07:59 PM
Thanks to captainprice12.
Back a little further.
Now, the following error message:

: 13: bad argument: int expected got nil
Kingdaro #8
Posted 06 October 2012 - 08:05 PM
You misspelled "gray".

Sorry that the libraries are written to American standards. If you wanted to fix that for yourself, you could edit the colors API with another program and put

colors.grey = colors.gray

at the end of it. For every program you wanted to give to others, though, you would put this at the top of that program.
Fatal_Exception #9
Posted 07 October 2012 - 12:46 AM
You misspelled "gray".

Sorry that the libraries are written to American standards. If you wanted to fix that for yourself, you could edit the colors API with another program and put

colors.grey = colors.gray

at the end of it. For every program you wanted to give to others, though, you would put this at the top of that program.

There's actually the colours api already for this reason. Only difference is grey vs gray.
fussel01 #10
Posted 07 October 2012 - 10:16 AM
Yes, that was the mistake. Now everything is satisfactory.
Thank you for your expert help.
I am going to try to better understand Lua.
But that was as I said my first program.

Sincerely yours
Fussel01