Problem with Entity Recording system?

Blitz3D Forums/Blitz3D Beginners Area/Problem with Entity Recording system?

Guy Fawkes(Posted 2011) [#1]
Hi all, I found an old code archives file that I need help fixing. For some reason it says object doesn't exist even though, clearly it DOES exist.



Some help on this matter would be GREATLY appreciated! :)

Thanks as usual! :)

Last edited 2011


Rob the Great(Posted 2011) [#2]
Typically, that error refers to Blitz trying to access a Type which doesn't exist. I don't have access to my PC right now, so I can't run the code, but I'm sure the error has something to do with the relationship between the frame index variable "CurrentFrame" and the internal index of the type list, e.g., the program currently has only 300 Type Objects but CurrentFrame is set to 301. In debug mode, what line is highlighted in the IDE when the error occurs? Check the CurrentFrame value when the error occurs. Also, check the values of the Type when the error occurs. If you see "null" in the type list, then it means that the current Type Object that Blitz is trying to read doesn't exist. This can be because it's been deleted, never created, or is referring to a Type Object outside of the list range.

I've only glanced through the code, but the next step is to know exactly where in the code the error is getting thrown out.


Guy Fawkes(Posted 2011) [#3]
The problem is with this line:

Frame(CurrentFrame)\x1# = EntityX(Entity,1)

Which is in RecordEntity() Function


Rob the Great(Posted 2011) [#4]
Wow, has this code been modified from its original source? Here's the problem, and it's explained in the commented sections of the code:
Global track = 1 ;this is the only time in the code the variable is set or changed
...
Function RecordEntity(Entity,Track=0) ;let's just say you want to record...Track = 1 is passed along, overriding track=0 in the function
     ...
	Select Track ;Remeber, track = 1, so only Case 1 will execute
	Case 0 ;This will NOT execute. Track = 1, not 0
		CurrentFrame = CurrentFrame + 1 ;increases the frame index. Nothing wrong here
		Frame.RecorderType(CurrentFrame)=New RecorderType ;CREATES A NEW TYPE. WITHOUT THIS LINE, NO TYPE OBJECTS EXISTS!
		Frame(CurrentFrame)\x0# = EntityX(Entity,1)
		Frame(CurrentFrame)\y0# = EntityY(Entity,1)
		Frame(CurrentFrame)\z0# = EntityZ(Entity,1)
		Frame(CurrentFrame)\p0# = EntityPitch(Entity,1)
		Frame(CurrentFrame)\w0# = EntityYaw(Entity,1)
		Frame(CurrentFrame)\r0# = EntityRoll(Entity,1)
	Case 1 ;This WILL execute because track = 1
                ;NOTE THAT YOU HAVE NOT CREATED A NEW TYPE LIKE ABOVE. THEREFORE, THE LINE BELOW WILL THROW OUT AN ERROR WHEN BLITZ TRIES TO SET THE TYPE VALUES.
                ;ALSO, CURRENTFRAME HAS NOT CHANGED LIKE IT DOES ABOVE.
		Frame(CurrentFrame)\x1# = EntityX(Entity,1)
		Frame(CurrentFrame)\y1# = EntityY(Entity,1)
		Frame(CurrentFrame)\z1# = EntityZ(Entity,1)
		Frame(CurrentFrame)\p1# = EntityPitch(Entity,1)
		Frame(CurrentFrame)\w1# = EntityYaw(Entity,1)
		Frame(CurrentFrame)\r1# = EntityRoll(Entity,1)
                ....

In its state as you presented, this code will always fail because in all of the recording/playback/saving functions, track=1 and no new types are ever created under that scenario. My only guess is that you should try changing the line "Global track=1" to "Global track=0" and see what happens. I don't know if it will fix the problem, but from what I can see, the track variable doesn't seem to serve the code very well. It could be used to save multiple recordings, but I'm not sure if it's fully tested or not.

Let us know if this resolves the problem.


Rob the Great(Posted 2011) [#5]

The problem is with this line:

Frame(CurrentFrame)\x1# = EntityX(Entity,1)

Which is in RecordEntity() Function


Yeah, that's what I figured. Go ahead and try changing "Global track = 1" to "Global track = 0", and I'll bet that will fix the problem.


Guy Fawkes(Posted 2011) [#6]
it fixed the problem, but now it wont even record or play back ><


Rob the Great(Posted 2011) [#7]
I was thinking something like that might come up. Unfortunately, without testing it myself, that's about all of the debugging I am able to do as of now. If you can give me a day or so, I can take a closer look and see what I can figure out. Or, someone else might be able to give you some pointers in the right direction.


Guy Fawkes(Posted 2011) [#8]
Thanks, I appreciate it! :) I'll check back tomorrow! :)