Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Baqck Again and yeah I have a problem

Author
Message
vampyre
17
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 13th Feb 2011 08:52 Edited at: 13th Feb 2011 08:54
Hi still working on my games "Solar Dominion" and "Astro Warrior" thought I would come back after I got really eed off last year. I keep getting a "Runtime error at line 459, object does not exist" but my object is in the folder and it does exist here is the code if I can get some help

I am using the Babe animated object out of Dark Matter Hover1 and Airplan.43 are in the Dark Basic Models folder or just replace them with a box model in either 3ds or X file formats

BN2 Productions
16
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 13th Feb 2011 09:48
Can you mark the line that is giving the error? I don't feel like counting 459 lines.

In general, that error usually means you are referencing a model that hasn't been loaded yet. So for instance:

MAKE OBJECT SPHERE 3,1
MOVE OBJECT 4,3

If you were to run just those two lines, the second one would give an Object Does Not Exist error because object 4 hasn't been loaded/created yet.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
vampyre
17
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 13th Feb 2011 10:20 Edited at: 13th Feb 2011 10:21
Sure No Problem BN2 Productions




BN2 Productions
16
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 13th Feb 2011 20:09
Alright, I don't have a definitive solution yet, but here is a good next step.

I ran your code expecting it to crash soon since I haven't assembled media for it. Incidentally, I got the same error on the same line, rather than a FILE DOES NOT EXIST error. I removed the SYNC ON command and the beginning and that seemed to fix things (ie I got the file does not exist error). So, remove the SYNC ON command and tell us what happens.

Why does this work: DBC doesn't crash until the next refresh (or a REALLY major problem). Some commands will require a refresh (my guess is that play object does). So while the code hit the error at (for me) line 31, it didn't stop until 459 (not to say it EXECUTED all those lines of code, it just 'skidded' to a halt that far).

Other notes:
You might want to look into your program structure. It looks like you are loading the same object every iteration through your DO loop. Furthermore you seem to have subroutines in there, but there is no call for the subroutines (using GOSUB). Place the subroutines outside of the loop and just use a GOSUB call to run the code.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
vampyre
17
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 14th Feb 2011 05:30
OK though I wanted to get away from the subroutines

just tried it and I am getting the same thing again but this time at line 58
vampyre
17
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 14th Feb 2011 05:51
I think I ned help with the GOSUB command really BN2 Productions
vampyre
17
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 14th Feb 2011 06:12 Edited at: 14th Feb 2011 07:58
Well did what you say but although it runs and doesn't crash nothing moves so I am missing an extra tiny something to make it work
Sorry here is the code

BN2 Productions
16
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 14th Feb 2011 09:19
It could be your If's. I noticed several that don't seem to have appropriately placed ENDIF's. For instance, right after the DO command, there is a line reading "if invehicle=2" this if is never closed (until perhaps the bottom). However, before that, there is another "if invehicle=2" at line 124.

My suggestion: you have a lot of code here, break it up into similar parts (movement, camera control, physics, etc) and use subroutines. That way your loop will be mostly a bunch of GOSUBs with a few IFs. It will also help keep it neat and as you sort through it, you will notice that some parts are missing some ENDIFs and such (I noticed a few more here and there that seemed to lack them).

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
vampyre
17
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 16th Feb 2011 10:55
Oh OK thank you BN2 but I am not too clued up on GOSUB still I will give it a try thanks
BN2 Productions
16
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 16th Feb 2011 11:11
Think of subroutines as replaceable parts for programming. My general rule for writing code:

1) Identify what needs to be done
2) Break that into constituent systems (movement, menu, physics, etc)
3) Each system is a subroutine (or multiple ones if necessary)
4) Your main loop contains NOTHING but if->thens or a SELECT statement that will call appropriate subroutines (I usually have a subroutine for each state of the game, such as menu, main game, etc, that has the code for the main loop).

Here's some pseudo code


If you want a visual demonstration of how sub's work, get a piece of paper. Draw a straight line. This line represents your code running without subroutines. It goes from A to B. No Variation. With Subs, however, you can draw the line however you want, you can go up down, left, right, in, out (but only if you're good at drawing 3d ) Since you are no longer restricted to a line, you can do anything you want.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 16th Feb 2011 14:15 Edited at: 16th Feb 2011 14:20
@vampyre
Quote: " I keep getting a "Runtime error at line 459, object does not exist" but my object is in the folder and it does exist here is the code if I can get some help"


Try a process of elimination. Run your original code, then whatever line DB says the error occurred at, comment out that line. So line 459 in this case would be changed from


to


Then run your code again. If the error happens again, you know it's not that line (alone). Comment out the next line that DB reports and so on until either the error changes to a new type of error (instead of object doesn't exist to maybe Syntax error something or whatever), or you don't get an error any more. If you don't get an error anymore, it's likely that the last line you commented out is the culprit or has a hand in the over-all problem.

As your are commenting out the lines, leave them commented out until you stop the error. Then uncomment them 1 at a time and work backwards until you fix the problem.

The structural suggestions BN2 has made will help you in the organization of your code and easier tracking down of problems.

EDIT:

I just noticed you have a RETURN in the middle of your code at line 424 all by itself. Is there a subroutine that this is tied to? If not it may be returning to a call that you did not intend or just causing trouble some other way.

Enjoy your day.
vampyre
17
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 22nd Feb 2011 00:02
Thank you BN2 and Latch sorry I haven't answered I have been away for a couple of days I think I will structure it the way Latch has laid it out in his psdeudo code it makes more logical sense

I will check out that line 424 Latch thanks for pointing it out to me

Login to post a reply

Server time is: 2020-08-12 02:33:21
Your offset time is: 2020-08-12 02:33:21