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

While true loop not looping and BigReactors controller not working

Started by Kyokun, 11 August 2015 - 05:21 PM
Kyokun #1
Posted 11 August 2015 - 07:21 PM
Hi there.
I've been running a bit into a wall during coding.
No matter what I try with this code, it won't work.
Not only does the screen information not change*, also will the "while true" loop not loop!
(Meaning that I can still type in the computer after executing the program and the variables will not update.)

Here is the code:
http://pastebin.com/0EwLgWmf

I have no idea what is wrong with it - perhaps somebody of you does.

Many thanks in advance,
Sincerely,
Kyokun

*The monitor setup itself works, I can change things in it fine outside of the "while true" loop, however they only change once when in the loop.
SquidDev #2
Posted 11 August 2015 - 08:08 PM
Just a couple of things, which may be relevant, some are just style changes:
  • Line 46: You have energyStoed instead of energyStored. This might cause a crash
  • Semicolons - you don't need them! Nor do you need brackets in the if statements
  • Line 35 & 42: The text inside should be in quotes - this again might be breaking things
  • Indent your code (have a look in the spoiler here for more info on that).
  • You can use if foo then and if not foo then instead of if foo == true then.
The code looks fine apart from that, so I'm not sure why it is breaking - do you get any errors when running it?
Kyokun #3
Posted 11 August 2015 - 08:41 PM
Just a couple of things, which may be relevant, some are just style changes:
  • Line 46: You have energyStoed instead of energyStored. This might cause a crash
  • Semicolons - you don't need them! Nor do you need brackets in the if statements
  • Line 35 & 42: The text inside should be in quotes - this again might be breaking things
  • Indent your code (have a look in the spoiler here for more info on that).
  • You can use if foo then and if not foo then instead of if foo == true then.
The code looks fine apart from that, so I'm not sure why it is breaking - do you get any errors when running it?

Hi, thanks for your reply.
I'm going to fix those typos and see what happens.
Furthermore, I'm an experienced coder and well aware of all the tricks etcetera, however I'm not familiar with lua and indenting is hard, as is typing in the computer.
I'll go through my code again and clean it up a bit, then report back.
Twijn #4
Posted 11 August 2015 - 09:56 PM
The code looks fine apart from that, so I'm not sure why it is breaking - do you get any errors when running it?

I've had times where while true do loops do NOT print out error messages, however that may have been my fault because I was using things like the parallel api and was clearing and rewriting the screen many times.

However, I believe the errors listed above may be causing it.
Kyokun #5
Posted 11 August 2015 - 11:35 PM
This is an update: Everything is fixed.
Sadly, I do not know what fixed it.
I just rewrote the whole code and somehow it's fixed. Weird.

Thank you everybody for your fast and instructive help.