Jump to content




error printing 12 and exiting with no print/write 12 or a vairable that could contain 12

help lua

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

#1 tebbenjo

  • Members
  • 16 posts

Posted 28 November 2012 - 05:05 PM

the goal / setup
I'm trying to make a program to time beer / rum and have persistent data, my setup is 14 booze barrels each with a button (attached to the first 14 colours of bundled cable, to the back of the computer) and a red stone lamp ( same but to the bottom) and a indicator lamp on each side of the computer. I want to time each barrel when the button is pressed to the amount of time the user types in, with persistent data be twine logins / chunks unloading.

the problem
my program prints 12 and exits even tough it shouldn't exit or print anything like 12 or any variable that could contain 12. to replicate the error; just run the program, no special circumstances required.

the code
warning this is a work in progress, load doesn't work yet and i'm just programming barrel number one first because the blocks relating to a specific barrel should tessellate with only minor adjustments. sorry for probably posting a stupid error and being noobie, but I spent all of my free time for the past weak on finding this error I.e. > 10 Hours but instead of rage quitting and probably being noobie forever i'll ask for help and hopefully learn something. so please help a noob in need.

Spoiler

Edited by tebbenjo, 29 November 2012 - 09:13 AM.
added code tags


#2 tebbenjo

  • Members
  • 16 posts

Posted 28 November 2012 - 05:08 PM

sorry forgot to mention, copy it into notepad++, it's much easier on the eyes, with syntax highlighting and actual line numbers, so it doesn't slur together like the black and white on this website.

#3 tebbenjo

  • Members
  • 16 posts

Posted 29 November 2012 - 05:35 AM

someone, help.

#4 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 29 November 2012 - 05:57 AM

You can use elseif instead of start a new if in the top of your program, in your timer function you can use the for loop instead of the while ... do loop this will make your code cleaner ;). And please indent and comment it, it's very hard to read it. I didn't see where you put a function that only print a variable... it really only print 12 ?

#5 tebbenjo

  • Members
  • 16 posts

Posted 29 November 2012 - 09:19 AM

View Postbjornir90, on 29 November 2012 - 05:57 AM, said:

You can use elseif instead of start a new if in the top of your program, in your timer function you can use the for loop instead of the while ... do loop this will make your code cleaner ;). And please indent and comment it, it's very hard to read it. I didn't see where you put a function that only print a variable... it really only print 12 ?

thank you, I made the changes you suggested, and removed the "work-in-progress" function load, as it isn't called anywhere yet, so was just taking up space and making things confusing.

and no not a function to print a variable; that's the problem, it shouldn't be printing any variables and there's no "print("12")"'s in there anywhere so why does 12 come up?

and yes the output is:

save started
timer started
main started
12

then it returns to the prompt.

#6 tebbenjo

  • Members
  • 16 posts

Posted 29 November 2012 - 10:59 AM

found it!!!!!!!!; miss copy to the computercraft computer, that interface is hard to use. I had "sleep(o)" instead of "sleep(0)" , so now i feel stupid. ohwhell I'll post the fished code hear when I do finish it then lock the post.

#7 Doyle3694

  • Members
  • 815 posts

Posted 29 November 2012 - 11:11 AM

Good job! ;) And the threads usually just die by themselfs, so no need to lock :P

#8 tebbenjo

  • Members
  • 16 posts

Posted 30 November 2012 - 11:54 AM

thank you, everybody. as I said I would Here's the fished code:

Spoiler

and some photos.
Spoiler






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users