Really strange problem with my program
-
So I've been working on a program for a while but just discovered a really strange problem.
I wasn't sure exactly how to make what wanted so I just kind of "winged it" and made a part where the code refers back to a variable ("screenW" which used the gwidth function) a few times to achieve what I was going for, it worked.
But now when I try to add one more line to this section it acts like the variable doesn't exist at all and gives an error message that refers to an unrelated line of code. Removing the new bit allows the program to work again. I thought maybe I used the same variable too many times or something so a made a new variable that also used gwidth. Running the program like this flashed a messed up version of the program on the screen for half a second then the Switch OS itself actually closed the program.
This probably all sounds quite incoherent, because it's kind of hard to explain the situation exactly. I have absolutely no idea how this happened. Is it a bug or did I just mess up the program so badly?
-
This post is deleted! -
Sorry to hear. What do you mean with messed version of code. Pixeled wise (graphic errors)or content wise(meaningles characters).
-
This post is deleted! -
@Something If it's possible, try to isolate the section which is giving you this problem, and maybe even start a new project which deliberately tries to trigger only that problem. It's quite difficult to speculate - it sounded initially like the error was to do with the screenW variable being out of scope - but you said that the program worked initially..
What was the code doing before it started happening, and then what was the section you added doing which caused it to trigger the problem?
-
I'm a little worried about triggering the problem as it as it was the actual Switch OS (does the Switch's OS have a name?) throwing me back to the home page, not Fuze. Does Fuze have some blocker which prevents me from messing up my system? Can I safely trigger the problem?
@Dave What do you mean by "out of scope"? Does that mean it was too far off the screen? It's a possibility, but I'm sure why it would do that. It's the same unfinished program I sent to you a while ago, I changed a few bits here and there then I finally wanted to bite the bullet and start the root system of my tree simulator, I wanted to place one more block under ground level and that's what started the problem.
@spikey So to explain roughly, imagine the level array from the tutorial, now imagine more blocks stacked in a tower resting on ground level roughly in the middle of the screen. The new addition that causes the problem should be just below ground level but instead appears strangely up and to the left of where it should be, but it only appeared for a moment before it stopped working.
@petermeisenstein I don't think it's a good idea for me to send this to anyone without knowing from the devs that it's safe to do so.
-
@Something No problem
-
@Something Thanks for the detailed reply. By out of scope I mean trying to access a variable which has been defined elsewhere in a different 'scope'. So, if you define variables at the top of your program, outside of any loops/functions etc, they are referred to as 'global'. Global variables can be accessed from anywhere in the program.
If I defined a variable in a function or within a loop for example, this would be referred to as 'local', and can only be accessed within that context.
Usually this will give an error stating "variableName does not exist" - and rarely have we had full crashes due to this.
When you say it was the actual Switch OS - you mean you get the message "Software closed due to an error" and you press an "OK" button? Don't worry - while this isn't exactly very nice to experience, there is no damage happening to your console.
-
That error message looks roughly like what I saw, that's a relief. Never had a crash on Switch before, just kind of expected error messages to come from Fuze and not the console. I'll try to test the problem in isolation.