Open main menu

Difference between revisions of "AGIWiki/Memory and Script"

m
Line 139: Line 139:
== Script Buffer ==
== Script Buffer ==


The script buffer stores an ordered list of commands such as loading/discarding resources, drawing/overlaying pictures and adding views to the background ([[AGIWiki/Add.to.pic|add.to.pic()]]) which are later saved in a save game. Because the memory layout is so dependent on order (as explained above), the script is necessary to ensure this order is conserved between save games. These commands are later executed from a restored game to ensure the interpreter is in the exact same state as it was when the game was saved. The script buffer is cleared when [[AGIWiki/New.room|new.room()]] is called so the script is room-centric.
The script buffer stores an ordered list of commands such as loading/discarding resources, drawing/overlaying pictures and adding views to the background ([[AGIWiki/add.to.pic|add.to.pic()]]) which are later saved in a save game. Because the memory layout is so dependent on order (as explained above), the script is necessary to ensure this order is conserved between save games. These commands are later executed from a restored game to ensure the interpreter is in the exact same state as it was when the game was saved. The script buffer is cleared when [[AGIWiki/new.room|new.room()]] is called so the script is room-centric.


The default size of the script buffer is 50 entries. Each entry is 2 bytes long so the default buffer size is 100 bytes. You can increase the size of the buffer by using the command [[AGIWiki/script.size|script.size()]]. Certain commands can increase script usage unless script writing has been disabled by setting flag 7 (script_blocked in template [[AGIWiki/defines.txt|<nowiki>#defines.txt</nowiki>]]). Care must be taken so that the game does not overflow the script buffer as this has been a cause of many problems. The interpreter keeps a record of the largest script size used in the game, which can be accessed from the command show.mem().
The default size of the script buffer is 50 entries. Each entry is 2 bytes long so the default buffer size is 100 bytes. You can increase the size of the buffer by using the command [[AGIWiki/script.size|script.size()]]. Certain commands can increase script usage unless script writing has been disabled by setting flag 7 (script_blocked in template [[AGIWiki/defines.txt|<nowiki>#defines.txt</nowiki>]]). Care must be taken so that the game does not overflow the script buffer as this has been a cause of many problems. The interpreter keeps a record of the largest script size used in the game, which can be accessed from the command show.mem().
885

edits