AGI Command Reference - Test Commands

From AGI Wiki
Revision as of 14:49, 28 December 2013 by Andrew Branscom (talk | contribs)
Jump to navigationJump to search

Tutorials and Guides Table of Contents
AGI Command Reference Index

Page: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16


Test Commands
By Chris Cromer

 

The result of test command can be either TRUE or FALSE.


equaln(n,m);

True if Var(n) = m.

equalv(n, m);

true if Var(n) = Var(m).

lessn(n,m);

True if Var(n) < m.

lessv(n, m);

True if Var(n) < Var(m)

.

greatern(n, m);

True if Var(n) > m.

greaterv(n, m);

True if Var(n) > Var(m).

isset(n);

True if Flag(n) = 1 (set).

isset.v(n);

True if Flag(Var(n)) = 1 (set).

has(n);

True if the room field of item n is 255, i.e. the item belongs to the player.

obj.in.room(n, m);

True if room field of the object n is Var(m).

posn(n, x1, y1, x2, y2);

True if the coordinates of the base point of the cel which is the current image of object n satisfies the equation x1 < = x < = x2, y1 < = y < = y2.

obj.in.box(n, x1, y1, x2, y2);

True if the base of the object n is completely within the rectangle specified using its top left (x1,y1) and bottom right (x2,y2) corners.

(x1, y1)
   ------------------
   |                |
   |                |
   |                |
   ------------------
                  (x2, y2)

center.position(n, x1, y1, x2, y2);

True of the center of the base line of the object n is inside the rectangle specified as its top left and bottom right corners.

right.position(n, x1, y1, x2, y2);

True of the right side of the base line of the object n is inside the rectangle specified as its top left and bottom right corners

.

have.key();

True if the user has pressed any key on the keyboard. Used to create cycles to wait until any key is pressed

.

compare.strings(s1, s2);

True if string(s1) = string(s2).

said(n, W(i));

where i = 1, ..., n True if the player has entered a phrase that completely matches W(1),...W(n), where n is the number of W(i) which are codes of the vocabulary words.
Here is how the input is matched. After the player types a message and presses Enter, the input line is processed by the interpreter.
Interpreter removes all punctuation marks.
All characters are converted to lowercase.
All sequences of more than one space are replaced with a single space.
Starting with the first word of the input, the interpreter looks up the vocabulary, trying to find the longest character sequence matching the entered.
If the search is unsuccessful, Var(9) is assigned the number of the word in the message that failed to match and the processing ends.
If all the words have been assigned some codes:

  • The Interpreter removes from the sequence of codes all zeros (that means all vocabulary words with zero codes are ignored).
  • Flag(2) (the user has entered an input line) is set to 1
  • Flag(4) ('said' command accepted the user input) is set to 0.

If the sequence of code produced by the interpreter is V(1), V(2),...V(m). The test is performed as follows: If Flag(2) = 0 or Flag(4) = 1, return FALSE. Compare parameters W(i) and codes V(i) as follows:

  • if W(i) = 1, it matches any V(i);
  • if W(i) = 9999, it matches the whole remaining input i.e. the codes V(i), V(i+1),...V(m).


Otherwise W(i) should be equal to V(i).
If all elements match, Flag(4) ('said' accepted the user input) is set to 1 and the command returns TRUE. Otherwise, FALSE is returned.

controller(n);

True if the event with code n has occurred:

  • a key with the code n was pressed (set using set_key);

menu item with code n was selected in command menu_input.

 

Page: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16


Tutorials and Guides Table of Contents
AGI Command Reference Index

< Previous: Menu Management CommandsNext: Other Commands >