send

From Wiki of ZZT
Revision as of 03:18, 13 February 2021 by RT-55J (talk | contribs) (whitespace)
Jump to navigation Jump to search

#send is a ZZT-OOP command that provides a means of directing one or multiple objects. When an object receives a message from #send, it checks its program for a matching label, and if found, continues program execution from that point. ZZT's manual compares it to the GOTO statement in BASIC.

Objects can send messages to themselves to control their own program flow, as well as send to other objects. An object can manage multiple instances of a label with #zap and #restore, allowing different reactions to the same received message string. If an object needs to perform a task without interruption, it can turn off all incoming messages with the #lock command.

Syntax

  • Object sending a label to itself: #send self:<label>
  • Object sending a label to multiple objects (and possibly itself as well): #send <all|others|name>:<label>

#send is unique among ZZT-OOP commands in that the command part can be omitted as a shortcut: #label is functionally identical to #send self:label, so long as :label exists somewhere in the code and label isn't the name of a command like #die.

Quirks

  • A locked object will not receive external messages, but it can still #send messages to itself. This includes when sending to all objects with #send all:label.