Give: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
(clarify visual bug, document more things)
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''#give''' and '''#take''' are [[ZZT-OOP]] commands for adding and subtracting to counters.
'''#give''' and '''#take''' are [[ZZT-OOP]] commands for adding and subtracting to counters.


The syntax for the commands is:
== Available counters ==
 
The following counters can be modified with '''#give''' and '''#take''':
 
* health
* ammo
* gems
* torches (''ZZT'' only)
* score
* time
* z (''Super ZZT'' only)
 
== Syntax ==


* <code>#give <counter> <amount> [<command>]</code>
* <code>#give <counter> <amount> [<command>]</code>
* <code>#take <counter> <amount> [<command>]</code>
* <code>#take <counter> <amount> [<command>]</code>
The following counters can be modified with '''#give''' and '''#take''':
* Health
* Ammo
* Gems
* Torches (''ZZT'' only)
* Score
* Time
* Z (''Super ZZT'' only)


If the '''#give''' or '''#take''' would result in the counter having a value less than 0 or greater than 32767, then the result of the operation is not stored, and the command is executed instead (if present). The command can be any ZZT-OOP command, but is usually the name of a [[Label|label]] to jump to, as in the following example:
If the '''#give''' or '''#take''' would result in the counter having a value less than 0 or greater than 32767, then the result of the operation is not stored, and the command is executed instead (if present). The command can be any ZZT-OOP command, but is usually the name of a [[Label|label]] to jump to, as in the following example:
Line 29: Line 31:
The command argument is rarely used with '''#give''', though it is available to use if necessary.
The command argument is rarely used with '''#give''', though it is available to use if necessary.


==Bugs and Quirks==
== Bugs and Quirks ==


* The Time counter actually stored the number of seconds ''elapsed'', not the number of seconds ''remaining''; as such, one has to '''#give''' time in order to reduce the amount of time remaining.
* The time counter actually stores the number of seconds ''elapsed'', not the number of seconds ''remaining''; as such, one has to '''#give''' time in order to reduce the amount of time remaining.
* The command argument does not need to be prefixed with an '''#'''; for example, '''#take gems 10 put s red key''' is as valid as '''#take gems 10 #put s red key'''.
* The command argument does not need to be prefixed with an '''#'''; for example, '''#take gems 10 put s red key''' is as valid as '''#take gems 10 #put s red key'''.
* ZZT displays sidebar numbers by adding a certain number of spaces to the value in question (two for ammo, one for other values). As such, a '''#take''' which reduces the value by a very large amount will cause a visual glitch. For example, '''#take health 95''' on '''Health: 100''' will display '''Health: 5 0''', while the true value of player health is equal to 5.
* ZZT displays sidebar numbers by adding a certain number of spaces to the value in question (two for ammo, one for other values). As such, a '''#take''' which reduces the value by a very large amount will cause a visual glitch. For example, '''#take health 95''' on '''Health: 100''' will display '''Health: 5 0''', while the true value of player health is equal to 5.

Latest revision as of 17:12, 29 September 2022

#give and #take are ZZT-OOP commands for adding and subtracting to counters.

Available counters

The following counters can be modified with #give and #take:

  • health
  • ammo
  • gems
  • torches (ZZT only)
  • score
  • time
  • z (Super ZZT only)

Syntax

  • #give <counter> <amount> [<command>]
  • #take <counter> <amount> [<command>]

If the #give or #take would result in the counter having a value less than 0 or greater than 32767, then the result of the operation is not stored, and the command is executed instead (if present). The command can be any ZZT-OOP command, but is usually the name of a label to jump to, as in the following example:

@GemsForHealth
#end
:touch
#take gems 10 tooPoor
#give health 50
#end
:tooPoor
You're to poor to buy health!

The command argument is rarely used with #give, though it is available to use if necessary.

Bugs and Quirks

  • The time counter actually stores the number of seconds elapsed, not the number of seconds remaining; as such, one has to #give time in order to reduce the amount of time remaining.
  • The command argument does not need to be prefixed with an #; for example, #take gems 10 put s red key is as valid as #take gems 10 #put s red key.
  • ZZT displays sidebar numbers by adding a certain number of spaces to the value in question (two for ammo, one for other values). As such, a #take which reduces the value by a very large amount will cause a visual glitch. For example, #take health 95 on Health: 100 will display Health: 5 0, while the true value of player health is equal to 5.
    • To work around this issue, one should #take values in smaller quantities.
  • Counters in ZZT are signed 16-bit values, as is the parsed integer; overflows and underflows outside the range -32768..32767 are not checked for.
    • The Turbo Pascal standard library function for parsing integers from strings, however, operates in 32 bits; this may cause different classes of bugs on 32-bit overflow. (TODO: what bugs?)