Set: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 19: Line 19:


In [[Super ZZT]] the flag limit has been increased to 16. Additionally, a flag prefixed with the letter "Z" can serve as the name for the [[Stones of Power]] counter. (Note that Super ZZT expects the initial "Z" to be uppercase, so keep that in mind if you choose to use an external editor to have the name of the Stones counter be mixed-case.)
In [[Super ZZT]] the flag limit has been increased to 16. Additionally, a flag prefixed with the letter "Z" can serve as the name for the [[Stones of Power]] counter. (Note that Super ZZT expects the initial "Z" to be uppercase, so keep that in mind if you choose to use an external editor to have the name of the Stones counter be mixed-case.)
== Syntax ==
<code>#set <flag></code>
<code>#clear <flag></code>
== Quirks ==
* Due to how the interpreter works, flags set with ZZT-OOP are limited to letters (a-z), numbers (0-9), colons (:) and underscores (_). The first character is not allowed to be a number. Other symbols will cut the string off: for example, <code>#set brick-wall</code> will assign the flag "BRICK".
* ZZT will technically allow setting flags with the same names as built-ins ([[contact]], [[blocked]], etc.), but attempting to read them with <code>[[if|#if]]</code> statements will always query the state of the built-in flag.
* Care must be exercised when editing flags with an external editor. If a flag name is not in all uppercase (e.g. <code>pants</code> instead of <code>PANTS</code>), then it will not be able to be referenced by any ZZT-OOP command.
== Myth ==
* At least two influential programming documents, ''[https://museumofzzt.com/file/z/zzttool.zip?file=ZZTTRICK.DOC Interesting Tricks and Techniques for ZZT and Super ZZT Object Programming]'' (ZZTTRICK.DOC) and ''[https://museumofzzt.com/file/z/zztptt.zip ZZT Programming Tricks and Techniques]'' (ZZTPTT.ZZT), claim that a flag can be set more than once ("double flags"), as any #set command with a flag that is already set will create another copy of the flag, and thus any instance where a flag may be set twice should have a #clear command to clear it first. This is incorrect, because as stated above, [https://github.com/asiekierka/reconstruction-of-zzt/blob/253a97774e24ed486a13b0ffa88e5a686b485ca2/SRC/OOP.PAS#L303-L324 the flag-setting procedure] checks for the existence of the specified flag and will not set it if it already exists, making an initial clearing procedure unnecessary.


{{ZZT-OOP navbox}}
{{ZZT-OOP navbox}}

Latest revision as of 17:04, 14 October 2023

The ZZT-OOP commands #set and #clear are used to set and clear flags from the world's flag list. Flags are strings limited to 20 characters in length, and only 10 flags can be set at a time. Internally, flags are converted into uppercase when set.

When using #set flag, ZZT checks to see if the flag has already been set. If it has been set already, then it does not set the flag again. If the flag has not been already set, then the flag is set in the first open flag slot. If no flag slot is open, then the last flag is overwritten.

The #clear flag command removes the flag from the flag list, replacing it with an empty string. Given how small the flag limit is, be sure to #clear flags when you are done with them. (If the flag list has been modified in an external editor to have multiple flags with the same name, then the last flag with the name will be removed.)

The presence of a flag can be detected using the #if command. For example:

#set flag
#if flag /e
#if not flag /w

The object in this scenario will move east, but will not move west.

Using the ? cheat prompt, the player can type +flag or -flag to set and clear flags manually. Several games have the player use this feature intentionally (eg to open an inventory menu) and not as a cheat.

Super ZZT

In Super ZZT the flag limit has been increased to 16. Additionally, a flag prefixed with the letter "Z" can serve as the name for the Stones of Power counter. (Note that Super ZZT expects the initial "Z" to be uppercase, so keep that in mind if you choose to use an external editor to have the name of the Stones counter be mixed-case.)

Syntax

#set <flag> #clear <flag>

Quirks

  • Due to how the interpreter works, flags set with ZZT-OOP are limited to letters (a-z), numbers (0-9), colons (:) and underscores (_). The first character is not allowed to be a number. Other symbols will cut the string off: for example, #set brick-wall will assign the flag "BRICK".
  • ZZT will technically allow setting flags with the same names as built-ins (contact, blocked, etc.), but attempting to read them with #if statements will always query the state of the built-in flag.
  • Care must be exercised when editing flags with an external editor. If a flag name is not in all uppercase (e.g. pants instead of PANTS), then it will not be able to be referenced by any ZZT-OOP command.

Myth