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

Program Silently Failing

Started by Brekkjern, 16 November 2013 - 09:13 PM
Brekkjern #1
Posted 16 November 2013 - 10:13 PM
I'm having real difficulties making this program run properly. Whenever I run it, it just silently fails. It outputs "batbox_6" on the monitor, but then the program stops without doing anything else. There is no error message at all.

Pastebin link: http://pastebin.com/jW98THPm

I just want to note that I am in no way a good coder. I have been following a few guides to make this work, but I do understand most of it.
Bomb Bloke #2
Posted 16 November 2013 - 11:21 PM
Does it return to the command prompt, or just stall?

Directly after writing the batbox's name, it should process line 61:

mon.write("\n\tEU: "..self.getStored().." / "..self.getCapacity()..". "..self.getPercent().."\%\n")

Not 100% sure, but I don't believe you can use escape characters with mon.write(). At least, I gather they don't work with term.write(), which should be much the same thing.

self.getStored() doesn't return anything, so what I'd expect to happen is an "attempt to concatenate nil and string" error. Not sure why you're not seeing an error appear; I suppose fix that and see what the result is?
Brekkjern #3
Posted 16 November 2013 - 11:36 PM
Does it return to the command prompt, or just stall?
It just returned to the command prompt, but what you suggested below actually fixed it.

self.getStored() doesn't return anything, so what I'd expect to happen is an "attempt to concatenate nil and string" error. Not sure why you're not seeing an error appear; I suppose fix that and see what the result is?
Such a frustrating mistake to make :(/>
I made it into a variable to do some checks on it to see why it didn't work and forgot to make it return again…

As for the mon.write() not working with escape characters, you are right. I guess I have to find a way around it.
Edited on 16 November 2013 - 10:42 PM