Difference between revisions of "AGIWiki/Memory and Script"

Jump to navigation Jump to search
m
corrected syntax -> source
m (corrected syntax -> source)
Line 256: Line 256:
However, script blocking is useful for small bits of code that don't allow the player to save or restore in between:
However, script blocking is useful for small bits of code that don't allow the player to save or restore in between:


<syntax type="C++">
<source lang="cpp">
#define script_blocked f7
#define script_blocked f7
   
   
Line 269: Line 269:
  reset(script_blocked);
  reset(script_blocked);
  }
  }
</syntax>
</source>


==== Save Script Position ====
==== Save Script Position ====
Line 276: Line 276:


The script works like this (you wouldn't use this in a game):
The script works like this (you wouldn't use this in a game):
<syntax type="C++">
<source lang="cpp">
  load.view(10); // script contains view 10
  load.view(10); // script contains view 10
  push.script();
  push.script();
  load.view(20); // script contains view 10, 20
  load.view(20); // script contains view 10, 20
  pop.script(); // script contains view 10
  pop.script(); // script contains view 10
</syntax>
</source>
To use in a real game, you need to initialise push.script first. This is similar to the first example in blocking script writing (but overkill):
To use in a real game, you need to initialise push.script first. This is similar to the first example in blocking script writing (but overkill):
<syntax type="C++">
<source lang="cpp">
  if (new_room)
  if (new_room)
  {
  {
Line 299: Line 299:
  pop.script(); // script doesn't contain either
  pop.script(); // script doesn't contain either
  }
  }
</syntax>
</source>
Here is my version of code to swap the ego's view and still letting the player save the game:
Here is my version of code to swap the ego's view and still letting the player save the game:


In the room logic (will be needed in all rooms):
In the room logic (will be needed in all rooms):
<syntax type="C++">
<source lang="cpp">
  if (new_room)
  if (new_room)
  {
  {
Line 316: Line 316:
   
   
  ...
  ...
</syntax>
</source>
Logic 70 - View switching logic. It can be given any number, just make sure it's the same in the calling logic.
Logic 70 - View switching logic. It can be given any number, just make sure it's the same in the calling logic.


<syntax type="C++">
<source lang="cpp">
#include "defines.txt"
#include "defines.txt"
   
   
Line 367: Line 367:
   
   
  return();
  return();
</syntax>
</source>


This is a better solution, because the script will have the correct views loaded when a game is restored and the script size will no increase each time the game is saved.
This is a better solution, because the script will have the correct views loaded when a game is restored and the script size will no increase each time the game is saved.
885

edits

Navigation menu