Give: Difference between revisions
Jump to navigation
Jump to search
m (→Bugs and Quirks: fix typo) |
No edit summary |
||
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. | ||
== 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> | ||
== Available counters == | |||
The following counters can be modified with '''#give''' and '''#take''': | The following counters can be modified with '''#give''' and '''#take''': | ||
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 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 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. |
Revision as of 17:11, 29 September 2022
#give and #take are ZZT-OOP commands for adding and subtracting to counters.
Syntax
#give <counter> <amount> [<command>]
#take <counter> <amount> [<command>]
Available counters
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?)
ZZT-OOP | |
---|---|
Prefixes |
|
Messages | |
Directions | |
Flags | |
Commands |