agidev.com
 Home | Intro | News | Games | Community | NAGI |  Articles  | Download | Links

Articles

AGI Error Code Tutorial v1.0

by Nick Sonneveld
Last updated 9th March, 2002

Page: 1 [ 2 ] 3 4 5 6

2. Logic Errors

The interpreter lets you define your own error messages for logic triggered errors.  Usually you would just use the stock list of error messages, but you could use it to define your own special-case error message code (to help with debugging).

Whenever a logic command decides that it just can't accept a certain arrangement of parameters, it calls a logic error.  The process it goes through is this:
  1. Stop sound
  2. Clear the memory all your loaded resources, not including logic.0
  3. Clears all input
  4. Beeps the speaker twice (I think - it may be too fast on my computer to hear it)
  5. Sets variable 17 (a system variable) with the type of error that occured (see table below)
  6. Sets variable 18 with secondary data that occured with the error (like a logic or object number)
  7. Jumps... to the start of the code that parses logic.0
  8. In logic.0, right at the start, it should check variable 17.  If it is bigger than 0 (which it will be if there's an error) it calls the error message logic.
  9. Loads this logic up and parses it
  10. The message logic prints a message according to var's 17 and 18.
  11. The message logic quits.
It should be pointed out that the error message logic should quit because the interpreter can't continue running in the start it's in.  In all games (tutorial and Sierra), it should check variable 17 right at the start of logic.0.  If the message logic looks messy, the strings are referring to other strings so the actual logic doesn't get too complicated.

Logic Error Types:  There are 23 known types of errors in the AGI interpreter.  The strange thing is that it doesn't actually generate all of these errors (at least in the PC version).  The programmers may have decided that it was too costly, performance-wise, to check it, or maybe it was an option at compile-time.  However, it's still useful to look at them as a whole.  They are not in any order, other than the order they implemented them all.

The list of types is as follows (v18 represents the value of variable 18, the error's secondary data).  I grouped errors when they were basically the same error:
"discard.view(v18):  View not loaded." Code 1 (v18=view number)
"set.view(_,v18):  View not loaded." Code 3 (v18=view number)
"sound(v18):  Sound not loaded." Code 9 (v18=sound number)
"draw.pic(v18):  Picture not loaded." Code 18 (v18=pic number)
"discard.pic(v18):  Picture not loaded." Code 21 (v18=pic number)
The interpreter has searched through it's lists for this particular resource and came up with nothing.  You have to make sure that you load the resource before you try and use it (load.sound, load.view, load.pic, load.logic).  Perhaps you're trying to specify the wrong resource or you haven't got around to adding it into your project yet.  You might have already discarded it, discarded the wrong thing, or you've tried to discard it but because of a looping bug, the logic is trying to discard it again.
"set.view(v18,_):  Bad object number." Code 2 (v18=obj number)
"set.loop(v18,_):  Bad object number." Code 4 (v18=obj number)
"set.cel(v18,_):  Bad object number." Code 7 (v18=obj number)
"erase(v18):  Bad object number." Code 12 (v18=obj number)
"animate.obj(v18):  Bad object number." Code 13 (v18=obj number)
"stop.update(v18):  Bad object number or object not drawn." Code 14 (v18=obj number)
"start.update(v18):  Bad object number or object not drawn." Code 17 (v18=obj number)
"draw(v18):  Bad object number." Code 19 (v18=obj number)
"get(v18) or put(v18):  Bad object number." Code 23 (v18=obj number)
You have tried to refer to an animated object that is out of range.  The file "object" sets the maximum limit of animated objects in a room.  In games using the template, this is set to 16, which means you can define objects o0 to o15.  If you try and specify an object out of this range for these particular commands, then the interpreter will throw an error.  Remember, this is the maximum number of animated objects in a ROOM.  If you find that you're running out of animated objects, try reducing the number of animated objects in that particular room or try and find out if you can reuse objects.  The ego is defined to use object o0 but you can use the rest for anything else.

It is possible to borrow an object file from another game, which you know to have a larger number defined.  Just strip out the name data and put in your own.  It's probably better off waiting for AGI Studio to support an option however.
"set.loop(v18,_):  View not set." Code 6 (v18=obj number)
"set.cel(v18,_):  View not set." Code 10 (v18=obj number)
"draw(v18):  View not set." Code 20 (v18=obj number)
The interpreter couldn't find any view resource associated with the animated object.  All animated objects have to be associated with a view resource before you can refer to it using these commands.  The best way would be to load a view (load.view) and then associate it (set.view).  Make sure the view resource is in memory (you may have accidently discared it) before you try and associate with the object, or the interpreter will throw an error.
"set.loop(v18,_):  Bad loop #." Code 5 (v18=obj number)
"set.cel(v18,_):  Bad cel #." Code 8 (v18=obj number)
You've tried to set a loop or cel for an animated object that doesn't exist in that view resource.  If you're setting a cel, make sure you're in the right loop first (there may be less cels in one loop than in another).  If you're setting a loop, make sure you have the right view resource associated with your animated object.
"Script buffer overflow.  Maximum size = v18" Code 11 (v18=max script size)
The script buffer, which contains a list of all the resources you've accessed in the current room (including whenever you discard), has run out of room.  The typical solution to this is to just increase the size of the script buffer. (You can call "script.size", but only do it ONCE, and right at the start of logic.0 before you open anything else)

If you find that you're running out of script space, no matter how large you make it, perhaps you should investigate why this is happening.  The most common reason is because, through an accidental bug, you're opening a resource over and over in a room logic and this fills up the script.  If you find that you have to load up lots of different resources (ie, different music for a jukebox each time the user plays a sound), you might have to separate that code into a separate room.

See the tutorial on the script buffer & memory if you want more information on this topic.
"print(v18): no message" Code 14 (v18=logic message number)
You have tried to print a string that does not exist in the current logic.  When you compile your logic code, the AGI Studio compiler matches up all the messages with the appropriate number.  But if you try and print a string that refers to another string that doesn't exist, or you use a compiler that doesn't check the messages then you will cause this error.  The best way to work around this is to look at the offending logic code and find out which message doesn't actually exist.

"no message" actually appears in later interpeters (around 2.9 and over.. I haven't checked earlier versions), earlier interpreters used Code 14 for the "stop.update" error.
"Bad test: v18" Code 15 (v18=test number)
"Bad action: v18" Code 16 (v18=action number)
You have tried to call an action or test that does not exist in the interpreter.  As the interpreters progressed through the different versions, the programmers decided to add extra commands to the library.  The problem with this is if you try to run a game that uses these commands on an older interpreter, it may not recognise the command.  You would probably be better off trying to run your game with a more recent interpreter or changing your logic code to not use that command.  The recent interpreters AGIL, NAGI and Sarien should support all the known commands.
"set.scan.start() already active in logic v18." Code 22 (v18=logic number?)
The PC interpeter does not generate this error, but the name was defined in a logic for a v3 game.  I'm assuming it's meant to generate this error if you call set.scan.start for a logic that already has it set.  If you do get this error (in an interpreter for another system perhaps?), then make sure you call "reset.scan.start" before calling "set.scan.start".

Page: 1 [ 2 ] 3 4 5 6