ID:732109
 
(See the best response by Forum_account.)
keyboard.dm:6346:error: var: Procedure is too large; break it into multiple sub-procedures

keyboard.dm:148:error: key_down: compile failed (possible infinite cross-reference loop)

I'm not familiar with the top error. Also when I removed the line that the 1st error highlighted it just highlighted the same line even though it was something completely different. The other error remained the same.

Does anyone know what went wrong here?
I think the first error just appears at the first line the compiler considers past the maximum proc length. I don't think I've ever seen it before, but that's just what makes sense.
You could show the code around the second problem, maybe. Don't show the whole thing, I'd like to keep my eyes.
Maximum proc length? So you mean I can't make that proc any larger? If this is the case then I will have to re-do a lot of the mechanics on my game. So before doing that I want to try and confirm this.

Does anyone knwo for sure or know any place I could check?
just try to re do the first proc and about second one its going on infinate loop
In response to Zerok Kaiba
Zerok Kaiba wrote:
Maximum proc length? So you mean I can't make that proc any larger? If this is the case then I will have to re-do a lot of the mechanics on my game. So before doing that I want to try and confirm this.

Does anyone knwo for sure or know any place I could check?

Try providing the code snippet of the procedure in question. Without it, we are simply making uneducated guesses.
Assuming these guesses are true, I don't doubt that the procedure can be re-worked and broken down, a lot. But we really really need to see the procedure here, to be able to offer any worthwhile advice.
Well, "key_down" makes me assume hes using one of F_A's libraries. Under that condition its safe to assume hes most likely looping a procedure that he wants to happen when hitting a key. Seems the procedure just is not reacting well with delays or somewhat. Ive had similar problems but i basically just rewrote said procedures into more detail and with plenty of comments in case i came across the problem with said procedure again. Assuming you are using his library's key_down procedure, rewrite the procedure/snippet your using again from scratch. Comment it out and see if there is any place it could loop repeatedly without a way to get out of it. Then fix that.

Other than what i just said, and my assumption being wrong, id suggest posting the part of your code that is causing the error so we can help debug it further.
The main problem and reason I would have to re-do a lot of stuff is my key_down() proc is incredibly long. notice the line the 1st errors reads on is 6346. Almost all of that is the proc and it continues on after that. So posting "snippets" wouldn't exactly work. Since it would take ages carefully inspecting the entire proc.

However I removed the last thing I did then added on some more to the proc to make it bigger than before but neither errors showed up. So I guess that means it didn't hit some maximum size or anything. Perhaps the 1st error was just reacting to the 2nd? I'm not sure but for now I'm okay. I'll post another reply to this if I ever encounter it in the future.

Also D-Cire is right. I'm using a pixel movement library that someone made, not sure of the name of the creator but the name of the library is something like "Forum_account.Sidescroller"
There's your answer, Zerok. The format of that name is "author.library_name". So, "Forum_account.Sidescroller" translates to "Sidescroller library made by Forum_account". AKA "F_A".
In response to Zerok Kaiba
Are you honestly suggesting you have a 6000 line procedure?
I didn't know there was a limit to how long a proc could be.

If you have one long proc, like this:

mob
key_down(k)
// 7000 lines of code here...

You can easily split it into two procs. Just move the last 3500 lines of code to a new proc and make the last thing in the first proc be a call to the second proc:

mob
key_down(k)
// 3500 lines of code here...
key_down2(k)

proc
key_down2(k)
// 3500 lines of code here...

Though, if you have that much code in one proc, there's probably a better way to organize things. I don't think I have a single project that has 6300 lines of code, so I'm guessing that you're doing more in keyboard.dm than just handling keyboard input.
No, it's all keyboard input. Thing is my game has characters and at the moment has 33 characters with 3-10 moves each. So the proc firstly checks which button I pressed and then finds which character I am and then executes that pin-pointed section of the entire procedure. However yes the way I'm coding it is tedious and unnecessary, so I took your advice and now when a button is pressed, key_down() identifies the key pressed and then calls the proc for that key.

So yea if anyone's wondering, the max capacity DM seems to allow for a procedure is 6300-6500 lines. Funny fact of the day or something I guess haha.
Best response
Zerok Kaiba wrote:
However yes the way I'm coding it is tedious and unnecessary

You still have to write the code for handling each key press and each ability that can be executed when a key is pressed. Writing code is always tedious =)

now when a button is pressed, key_down() identifies the key pressed and then calls the proc for that key.

That's the way I do things - key_down() just figures out what proc needs to be called and calls it. The code to perform the action isn't in key_down at all. Now, to bore you with some details...

The reason why that's better is because it lets you re-use the code in different ways. If the code to execute a special attack is inside key_down(), you can't make an AI-controlled mob use the same special attack. Also, with the way you had it structured, if two characters share a common ability, you may have had to repeat the code for each character. If you have the code for each ability in its own proc you can call that proc from anywhere.

Also, instead of having a single key_down() proc for all mobs, you can make a different type of mob for each character and give each one its own key_down() proc:

// instead of doing something like this:
mob
key_down(k)
if(character == "character1")
if(k == "x")
punch()
else if(character == "character2")
if(k == "x")
kick()

// do something like this:
mob
character1
key_down(k)
if(k == "x")
punch()

character2
key_down(k)
if(k == "x")
kick()