Jump to content




While true loop not looping and BigReactors controller not working

api lua computer

4 replies to this topic

#1 Kyokun

  • Members
  • 3 posts

Posted 11 August 2015 - 06: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.

#2 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 11 August 2015 - 07: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?

#3 Kyokun

  • Members
  • 3 posts

Posted 11 August 2015 - 07:41 PM

View PostSquidDev, on 11 August 2015 - 07:08 PM, said:

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.

#4 Twijn

  • Members
  • 119 posts

Posted 11 August 2015 - 08:56 PM

View PostSquidDev, on 11 August 2015 - 07:08 PM, said:

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.

#5 Kyokun

  • Members
  • 3 posts

Posted 11 August 2015 - 10: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users