Give: Difference between revisions
Jump to navigation
Jump to search
(Yes, I verified the #give thing [command] thing in ZZT itself and in the source. You really can be :tooRich) |
No edit summary |
||
(6 intermediate revisions by 2 users 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. | ||
== 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>#take <counter> <amount> [<command>]</code> | ||
If the | 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: | ||
< | <nowiki>@GemsForHealth | ||
@GemsForHealth | #end | ||
#end | :touch | ||
:touch | #take gems 10 tooPoor | ||
#take gems 10 tooPoor | #give health 50 | ||
#give health 50 | #end | ||
#end | :tooPoor | ||
:tooPoor | You're to poor to buy health!</nowiki> | ||
You're to poor to buy health! | |||
</ | |||
The command argument is rarely used with '''#give''', though it is available to use | 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 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 time counter is | * 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 navbox}} | {{ZZT-OOP navbox}} |
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?)
ZZT-OOP | |
---|---|
Prefixes |
|
Messages | |
Directions | |
Flags | |
Commands |