Give

From Wiki of ZZT
Jump to navigation Jump to search

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

The syntax for the commands is:

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

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 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?)