プレイ日記
Josiah Spike4
How do you stop "stack overflows"?
5そうだね
プレイ済み
返信[1]
親投稿
Hanzo rzsense
Please check the following points. Don't you escape from a subroutine without "RETURN" after you have jumped to the subroutine with "GOSUB"? Isn't the nest of recursive function call too deep?
0そうだね
未プレイ
返信[2]
親投稿
mystman12 mystman12
I assume you're using GOSUB in your code, right? Make sure you have a RETURN to return to your main loop. Basically, the game seems to be running out of memory because it keeps getting a GOSUB without a RETURN, like this: @T1 GOSUB @T2 @T2 GOTO @T1 SmileBASIC tries to keep track of where the last GOSUB was so it can return there once it hits the RETURN command; However, it can also...
0そうだね
プレイ済み
返信[3]
親投稿
mystman12 mystman12
stack these, so you can use multiple GOSUBS and still remember all the previous ones. For example, you can make code that GOSUBS out of the main loop into an input section of code, and then GOSUB it again to, say, the code that activates when you press UP, and you could GOSUB it *again* to the code that moves the player up if there are no obstacles in the way, and this can go on and on. Once it...
0そうだね
プレイ済み
返信[4]
親投稿
mystman12 mystman12
reaches a RETURN, it will return where it left off in the moving code, and then the next RETURN would return it to where it left off in the input code, and one more RETURN would return it to where it left off in the main loop. The catch is that there's a limit to just how much you can GOSUB before RETURNing, and often times there may be an error in your code that causes this to happen...
0そうだね
プレイ済み
返信[5]
親投稿
mystman12 mystman12
You might have a GOTO @LOOP where you should have a RETURN, or maybe you just used to many GOSUBS! Check the line the error occurred on, and try to figure out exactly where the code is going. You probably just need to change a GOTO to a RETURN or remove an unecessary GOSUB. Hope this helps! (And that it wasn't too long. :P)
0そうだね
プレイ済み
返信[6]
親投稿
Josiah Spike4
Well I have returns, so thats not the problem. I don't have gotos instead returns, so thats not the problem. I may have too many gosubs. This game has over 2000 lines of code and I may overuse gosubs. So if I did have too many gosubs, what would I do to fix the stack overflows.
0そうだね
プレイ済み
返信[7]
親投稿
mystman12 mystman12
Hmm, I'm not sure... Does the error occur quickly after starting or only after certain actions? I really can't give you a solid answer, I'm just trying to give you the best advice I've got, sorry.
0そうだね
プレイ済み
返信[8]
親投稿
Josiah Spike4
It's usually after a while of running the program.
0そうだね
プレイ済み
返信[9]
親投稿
mystman12 mystman12
Hmm, that's strange. The best thing to do is to look at your code around where the error occurs, and try to figure out if it is linked to any specific actions. (Like, does it always happen while you're moving down, for example?) Just try to figure out what the code is doing and why it's missing a RETURN. Hopefully I've sent you in the right direction and haven't just confused you. :P
0そうだね
プレイ済み
返信[10]
親投稿
Hanzo rzsense
I recommend you not to use deep nest subroutine call. A subroutine should be called after another subroutine has returned over. SmileBASIC's stack must not be so deep. Actually, I'm looking forward to the completion of this game. I'd like to support you as much as I could in order to fix the problem. Is it possible to show us line 349 of your code?
0そうだね
未プレイ
返信[11]
親投稿
Josiah Spike4
Here it is. Maybe you can see whats wrong with it. I think I'm calling to that area too many times. what do you think? ;)
0そうだね
プレイ済み
返信[12]
親投稿
mystman12 mystman12
Hold up. What happens @DEAD? Does it reset the game or return to the main menu? If it does anything like that then it should probably be GOTO instead. Try that and see what happens!
0そうだね
プレイ済み
返信[13]
親投稿
Josiah Spike4
I changed a ton of stuff to GOTO since I found out that GOTOS are different than GOSUBS and it worked for now. I GOT TO 40000 WHITHOUT A STACK OVER FLOW!! :)
1そうだね
プレイ済み