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

[Lua] [Error] function problems

Started by ssalogel, 16 January 2013 - 03:31 PM
ssalogel #1
Posted 16 January 2013 - 04:31 PM
Hi guys!

I was making my first program tonight, and althought everything should work, I can't make the functions work.

all the code, if repeated all throughout the program, works, but it's terribly inefficient if I want to change something. So I decided to put things in function.

Ho and behold! I now get 338 errors at the "while" in each function, while they work outside of it. Here's the pastebin if someone want to take a look: http://pastebin.com/vNuYNQTK


thanks!
theoriginalbit #2
Posted 16 January 2013 - 04:34 PM
I don't see how this worked before…

line 3 you have While instead of while… Lua is case sensitive
line 6 should be timeUp = timeUp + 1
line 12 you have the operator != in lua not equals is ~=
line 14 should be timeUp = timeUp - 1
ssalogel #3
Posted 16 January 2013 - 04:47 PM
uh. most of these correction are made in my program… must have pastebin the wrong one –'

case sensitive though, hadn't catch that one.

and by saying that they all worked, I meant that I had tested the concept (as in, a while detect then this and that, does it work)


tried the correction, now it's expecting a "do" on line 12… which already has a "do" >_<

http://pastebin.com/ASAvjf9m

edit: forgot to initialise timeUp. do they have a default or do they just take a "random" value, as in real life? initialising timeUp at 0 gets rid of the "do" expectation

now it's expecting an "=" on line 14… which already got one…
theoriginalbit #4
Posted 16 January 2013 - 04:50 PM
and by saying that they all worked, I meant that I had tested the concept (as in, a while detect then this and that, does it work)
So logic test then…


edit: forgot to initialise timeUp. do they have a default or do they just take a "random" value, as in real life?
yep just about to say that… nope, they are nil…

line 13 you are missing the () at the end of the function call
ssalogel #5
Posted 16 January 2013 - 04:52 PM
Thank you! those parenthesis were the only things missing!

it works now :)/>

so, need to be more carefull next time :)/>
theoriginalbit #6
Posted 16 January 2013 - 04:53 PM
Thank you! those parenthesis were the only things missing!

it works now :)/>

so, need to be more carefull next time :)/>

Its ok, it happens to the best of us ;)/>