18 posts
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
1688 posts
Location
'MURICA
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.
521 posts
Location
Stockholm, Sweden
Posted 06 October 2012 - 07:30 PM
At the bottom, instead of using shell.run("reboot") you could do os.reboot()
1688 posts
Location
'MURICA
Posted 06 October 2012 - 07:34 PM
What if he wants it to print "Goodbye"? XD
18 posts
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
33 posts
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
18 posts
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
1688 posts
Location
'MURICA
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.
105 posts
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 colo
urs api already for this reason. Only difference is grey vs gray.
18 posts
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