Difference between revisions of "AGI Studio Template Game"
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | The '''AGI Studio Template Game''' is a one-[[Room|room]] game that serves as a starting point for game authors to build their own games. It features a default [[View|view]] for [[Ego|ego]], a blank [[Picture|picture resource]] that is used by the first [[Room|room]] in the game, and a default [[Inventory | + | The '''AGI Studio Template Game''' is a one-[[AGI Room|room]] game that serves as a starting point for game authors to build their own games. It features a default [[AGI View Resource|view]] for [[AGI Ego|ego]], a blank [[AGI Picture Resource|picture resource]] that is used by the first [[AGI Room|room]] in the game, and a default [[AGI Inventory Object|inventory object]]. |
− | Perhaps most importantly, the template game provides a significant amount of code that implements basic functionality such as setting up the game's menus, saving and restoring, and a set of [[Debugging|debugging]] commands. Without the template game, game programmers would have to implement these features themselves. | + | Perhaps most importantly, the template game provides a significant amount of code that implements basic functionality such as setting up the game's menus, saving and restoring, and a set of [[AGI Debugging|debugging]] commands. Without the template game, game programmers would have to implement these features themselves. |
− | The template game also provides a file called [/index.php/Defines.txt defines.txt] that sets up [[Defines|defines]] for the [[Special variables|special variables]], [[Special flags|special flags]], and other data that are of special meaning to the [[Interpreter|interpreter]] or that are used by the template game itself. The game's author should use this file to avoid the need to redefine all those items. | + | The template game also provides a file called [/index.php/Defines.txt defines.txt] that sets up [[AGI Defines|defines]] for the [[AGI Special variables|special variables]], [[AGI Special flags|special flags]], and other data that are of special meaning to the [[AGI Interpreter|interpreter]] or that are used by the template game itself. The game's author should use this file to avoid the need to redefine all those items. |
− | == Updates to the template game == | + | == <br />Updates to the template game == |
− | Since the original version of the template game, there have been a few updates to make it even more convenient to use. [[ | + | Since the original version of the template game, there have been a few updates to make it even more convenient to use. [[Chris Cromer]] updated the template game to add a convenient debug menu, among other things. |
+ | | ||
== Errors in the template game == | == Errors in the template game == | ||
Although the template game has been generally bug-free for a long time, from time to time, errors have slipped in. Some of these are not proper "bugs" but they nevertheless are worth mentioning. | Although the template game has been generally bug-free for a long time, from time to time, errors have slipped in. Some of these are not proper "bugs" but they nevertheless are worth mentioning. | ||
− | === | + | |
+ | === input_received === | ||
− | The original template game misspelled the define name <code>input_received</code> as <code> | + | The original template game misspelled the define name <code>input_received</code> as <code>input_received</code>. This is why programs such as the [[AGI Base Logic Generator|AGI Base Logic Generator]] misspell the define name by default. |
The spelling error was corrected in updates to the template game. | The spelling error was corrected in updates to the template game. | ||
+ | | ||
=== Memory leak on teleport (general) === | === Memory leak on teleport (general) === | ||
− | During the attempts to update the template game with useful features such as a new debugging menu, a bug was inadvertently introduced that caused the debugging command "tp" to leak memory, eventually leading to an [[Out of | + | During the attempts to update the template game with useful features such as a new debugging menu, a bug was inadvertently introduced that caused the debugging command "tp" to leak memory, eventually leading to an [[Out of Memory Error|out of memory error]]. |
You know if your version of the template game contains the bug if the following code appears in LOGIC.000: | You know if your version of the template game contains the bug if the following code appears in LOGIC.000: | ||
<div class="CodeBlockHeader">Code:</div> | <div class="CodeBlockHeader">Code:</div> | ||
− | |||
<syntaxhighlight lang="agi"> | <syntaxhighlight lang="agi"> | ||
if (new_room) { // First interpreter cycle in a new room | if (new_room) { // First interpreter cycle in a new room | ||
Line 39: | Line 41: | ||
// on this cycle (if turned on) | // on this cycle (if turned on) | ||
} | } | ||
+ | </syntaxhighlight> | ||
− | |||
If this code ''does'' appear in your version of the template game, then you should change it to: | If this code ''does'' appear in your version of the template game, then you should change it to: | ||
<div class="CodeBlockHeader">Code:</div> | <div class="CodeBlockHeader">Code:</div> | ||
− | |||
<syntaxhighlight lang="agi"> | <syntaxhighlight lang="agi"> | ||
if (new_room) { // First interpreter cycle in a new room | if (new_room) { // First interpreter cycle in a new room | ||
Line 62: | Line 63: | ||
// on this cycle (if turned on) | // on this cycle (if turned on) | ||
} | } | ||
− | </syntaxhighlight> | + | </syntaxhighlight> |
+ | |||
This bug has since been corrected in the template game that is available from http://www.agigames.com<nowiki>; however, </nowiki>[[AGI Studio|AGI Studio]] may still be packaged with the version containing the bug. | This bug has since been corrected in the template game that is available from http://www.agigames.com<nowiki>; however, </nowiki>[[AGI Studio|AGI Studio]] may still be packaged with the version containing the bug. | ||
+ | | ||
=== Memory leak on teleport to room 0 === | === Memory leak on teleport to room 0 === | ||
− | While not properly a "bug," it is true that both the original and updated template games used to allow you to use a "tp" debugging command to teleport to [[Room|room]] 0, which attempts to use [[Logic 0|logic 0]] as a room. This causes memory leaks and can eventually lead to an [[Out of | + | While not properly a "bug," it is true that both the original and updated template games used to allow you to use a "tp" debugging command to teleport to [[AGI Room|room]] 0, which attempts to use [[AGI Logic 0|logic 0]] as a room. This causes memory leaks and can eventually lead to an [[Out of Memory Error|out of memory error]]. |
The biggest trouble with this bug is that once you type "tp" and press Enter there is no way to cancel the teleport. Pressing Enter with a blank entry is the same as entering 0. Fortunately, there is a simple fix. In LOGIC.099, find the code that reads: | The biggest trouble with this bug is that once you type "tp" and press Enter there is no way to cancel the teleport. Pressing Enter with a blank entry is the same as entering 0. Fortunately, there is a simple fix. In LOGIC.099, find the code that reads: | ||
<div class="CodeBlockHeader">Code:</div> | <div class="CodeBlockHeader">Code:</div> | ||
− | |||
<syntaxhighlight lang="agi"> | <syntaxhighlight lang="agi"> | ||
if (said("tp")) { | if (said("tp")) { | ||
Line 78: | Line 80: | ||
new.room.v(v255); | new.room.v(v255); | ||
} | } | ||
− | </syntaxhighlight> | + | </syntaxhighlight> |
+ | |||
Then change it to: | Then change it to: | ||
<div class="CodeBlockHeader">Code:</div> | <div class="CodeBlockHeader">Code:</div> | ||
− | |||
<syntaxhighlight lang="agi"> | <syntaxhighlight lang="agi"> | ||
if (said("tp")) { | if (said("tp")) { | ||
Line 93: | Line 95: | ||
} | } | ||
} | } | ||
− | </syntaxhighlight | + | </syntaxhighlight> |
− | Alternately, you can eliminate the "Can't tp to room 0" message and change the inner [[If | + | |
+ | Alternately, you can eliminate the "Can't tp to room 0" message and change the inner [[If Statement (AGI)|if statement]] to read: | ||
<div class="CodeBlockHeader">Code:</div> | <div class="CodeBlockHeader">Code:</div> | ||
− | |||
<syntaxhighlight lang="agi"> | <syntaxhighlight lang="agi"> | ||
if (v255 != 0) { | if (v255 != 0) { | ||
new.room.v(v255); | new.room.v(v255); | ||
} | } | ||
− | </syntaxhighlight> | + | </syntaxhighlight> |
+ | |||
This issue has also been corrected in the latest releases of the template game, available from http://www.agigames.com<nowiki>; however, </nowiki>[[AGI Studio|AGI Studio]] may still be packaged with the buggy version of the template game. | This issue has also been corrected in the latest releases of the template game, available from http://www.agigames.com<nowiki>; however, </nowiki>[[AGI Studio|AGI Studio]] may still be packaged with the buggy version of the template game. | ||
+ | | ||
=== Incorrect volume controls === | === Incorrect volume controls === | ||
− | The original versions of the template game attempted to control the sound volume by using the [[Special | + | The original versions of the template game attempted to control the sound volume by using the [[AGI Special Variables|special variable]] <code>v23</code> (or <code>sound_volume</code> in the template game. |
− | + | Counter intuitively setting <code>v23</code> to 0 produces the loudest sound and setting setting <code>v23</code> to 15 produces no sound. The original template game assumed that the volume increased as the value of <code>v23</code> increased, but this is not the case. | |
This issue has also been corrected in the latest releases of the template game, available from http://www.agigames.com<nowiki>; however, </nowiki>[[AGI Studio|AGI Studio]] may still be packaged with the buggy version of the template game. | This issue has also been corrected in the latest releases of the template game, available from http://www.agigames.com<nowiki>; however, </nowiki>[[AGI Studio|AGI Studio]] may still be packaged with the buggy version of the template game. | ||
− | |||
[[Category:Debugging]] | [[Category:Debugging]] | ||
+ | [[Category:AGI Debugging]] |
Latest revision as of 10:27, 28 March 2019
The AGI Studio Template Game is a one-room game that serves as a starting point for game authors to build their own games. It features a default view for ego, a blank picture resource that is used by the first room in the game, and a default inventory object.
Perhaps most importantly, the template game provides a significant amount of code that implements basic functionality such as setting up the game's menus, saving and restoring, and a set of debugging commands. Without the template game, game programmers would have to implement these features themselves.
The template game also provides a file called [/index.php/Defines.txt defines.txt] that sets up defines for the special variables, special flags, and other data that are of special meaning to the interpreter or that are used by the template game itself. The game's author should use this file to avoid the need to redefine all those items.
Updates to the template game
Since the original version of the template game, there have been a few updates to make it even more convenient to use. Chris Cromer updated the template game to add a convenient debug menu, among other things.
Errors in the template game
Although the template game has been generally bug-free for a long time, from time to time, errors have slipped in. Some of these are not proper "bugs" but they nevertheless are worth mentioning.
input_received
The original template game misspelled the define name input_received
as input_received
. This is why programs such as the AGI Base Logic Generator misspell the define name by default.
The spelling error was corrected in updates to the template game.
Memory leak on teleport (general)
During the attempts to update the template game with useful features such as a new debugging menu, a bug was inadvertently introduced that caused the debugging command "tp" to leak memory, eventually leading to an out of memory error.
You know if your version of the template game contains the bug if the following code appears in LOGIC.000:
<syntaxhighlight lang="agi">
if (new_room) { // First interpreter cycle in a new room // Note: Everything other than logic 0 is discarded // from memory when new.room is executed load.logics(90); // Load game specific functions logic into memory clear.lines(24,24,0); // clear bottom line of screen (remove ego's coords if shown) animate.obj(ego); load.view.v(ego_view_no); set.view.v(ego, ego_view_no); observe.objs(ego); old_clock_seconds = 255; // make sure clock gets updated this cycle // on this cycle (if turned on) }
</syntaxhighlight>
If this code does appear in your version of the template game, then you should change it to:
<syntaxhighlight lang="agi">
if (new_room) { // First interpreter cycle in a new room // Note: Everything other than logic 0 is discarded // from memory when new.room is executed load.logics(90); // Load game specific functions logic into memory if (debug_active) { load.logics(99); // load debug logic into memory } clear.lines(24,24,0); // clear bottom line of screen (remove ego's coords if shown) animate.obj(ego); load.view.v(ego_view_no); set.view.v(ego, ego_view_no); observe.objs(ego); old_clock_seconds = 255; // make sure clock gets updated this cycle // on this cycle (if turned on) }
</syntaxhighlight>
This bug has since been corrected in the template game that is available from http://www.agigames.com; however, AGI Studio may still be packaged with the version containing the bug.
Memory leak on teleport to room 0
While not properly a "bug," it is true that both the original and updated template games used to allow you to use a "tp" debugging command to teleport to room 0, which attempts to use logic 0 as a room. This causes memory leaks and can eventually lead to an out of memory error.
The biggest trouble with this bug is that once you type "tp" and press Enter there is no way to cancel the teleport. Pressing Enter with a blank entry is the same as entering 0. Fortunately, there is a simple fix. In LOGIC.099, find the code that reads:
<syntaxhighlight lang="agi">
if (said("tp")) { get.num("new room: ", v255); new.room.v(v255); }
</syntaxhighlight>
Then change it to:
<syntaxhighlight lang="agi">
if (said("tp")) { get.num("new room: ", v255); if (v255 == 0) { print("Can't tp to room 0"); } else { new.room.v(v255); } }
</syntaxhighlight>
Alternately, you can eliminate the "Can't tp to room 0" message and change the inner if statement to read:
<syntaxhighlight lang="agi">
if (v255 != 0) { new.room.v(v255); }
</syntaxhighlight>
This issue has also been corrected in the latest releases of the template game, available from http://www.agigames.com; however, AGI Studio may still be packaged with the buggy version of the template game.
Incorrect volume controls
The original versions of the template game attempted to control the sound volume by using the special variable v23
(or sound_volume
in the template game.
Counter intuitively setting v23
to 0 produces the loudest sound and setting setting v23
to 15 produces no sound. The original template game assumed that the volume increased as the value of v23
increased, but this is not the case.
This issue has also been corrected in the latest releases of the template game, available from http://www.agigames.com; however, AGI Studio may still be packaged with the buggy version of the template game.