Jump to content




[Lua] [Error] function problems


  • You cannot reply to this topic
5 replies to this topic

#1 ssalogel

  • Members
  • 5 posts

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!

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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

#3 ssalogel

  • Members
  • 5 posts

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...

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 January 2013 - 04:50 PM

View Postssalogel, on 16 January 2013 - 04:47 PM, said:

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...


View Postssalogel, on 16 January 2013 - 04:47 PM, said:

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

#5 ssalogel

  • Members
  • 5 posts

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 :)

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 January 2013 - 04:53 PM

View Postssalogel, on 16 January 2013 - 04:52 PM, said:

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 ;)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users