Item (ZScript)

From ZCWiki
Jump to: navigation, search

The keyword item specifies that a variable is a pointer (a reference) to an item, such as a Rupee, on the screen.

Syntax and Initialization

Declare a variable as type item as follows:

item AnItem;

Until you initialze the variable, it does not actually "point to" any particular item, and thus any properties or methods you attempt to use will be invalid. You must initialize the variable by using the Screen->CreateItem or Screen->LoadItem methods, as follows:

// You can initialize at declaration...
item AnItem = Screen->LoadItem(1);

// ...or you can initialize later.
AnItem = Screen->LoadItem(1);

Properties and Methods

Properties

int ASpeed

The speed at which this item animates, in screen frames.

int CSet

This item's CSet.

itemdata Data

Retrieves a pointer to the itemdata associated to this object, which contains more properties of the object.

int Delay

The amount of time the animation is suspended after the last frame, before the animation restarts, in item frames. That is, the total number of screen frames of extra wait is Delay*ASpeed.

int DrawStyle

An integer representing how the item is to be drawn. Use one of the DS_ constants in std.zh to set or compare this value.

int Extend

The item's link tile modifier.

bool Flash

Whether or not the item flashes. A flashing item alternates between its CSet and its FlashCSet.

int FlashCSet

The CSet used during this item's flash frames, if this item flashes.

int Flip

Whether and how the weapon's tiles should be flipped.

  • 0: No flip
  • 1: Vertical flip
  • 2: Horizontal flip
  • 3: Rotate 180 degrees
  • 4: Rotate clockwise 90 degrees
  • 7: Rotate counter-clockwise 90 degrees

int Frame

The tile that is this item's current animation frame.

int NumFrames

The number of frames in this item's animation.

int OriginalTile

The starting tile of the item's animation.

int Tile

The tile associated with this item.

int X

The item's X position on the screen, in pixels.

int Y

The item's Y position on the screen, in pixels.

Methods

isValid

The isValid method indicates whether or not this item pointer is still valid. A return value of true indicates the pointer is still valid.

An item pointer becomes invalid when Link picks up the item, the item fades away, or Link leaves the screen. Accessing any variables using an invalid item pointer prints an error message to allegro.log and does nothing.

Introduced in Version
2.5 (beta)
Prototype and Arguments
bool isValid()


See Also