ShiftContents

Category: Objects / Contents
Since engine version: 1.0 OC

Description

Resorts the contained objects so the next object with a differing ID will be in front. The most common application for this command is inventory selection.

Syntax

bool ShiftContents(bool shift_back, id target_id, bool no_calls);

Parameters

shift_back:
[opt] If true, objects will be resorted backwards.
target_id:
[opt] ID of the object type to be in front after the shift. If this parameter is specified, no call to ControlContents will be made. The object will be selected directly and without the selection sound. In this way you can overload the contents switching in ControlContents and add your own sounds or special events.
no_calls:
[opt] If true, calls to ControlContents and Selection will be made.

Remarks

This command calls the function "ControlContents" in the container object which can be used to overload the selection process. If the function ControlContents does not exist in the container object or returns false, the function "Selection" will be called in the newly selected inventory object. If the function Selection does not exist in the contained object or returns false, the engine will play the "Grab" sound effect for the container object (default behaviour for inventory selection). See also object scripts.
Notice: nowadays the function ShiftContents will also play the selection sound. To avoid double playback, object scripts should take this into consideration and not play their own selection sound or move the sound playback to the ControlContents function, as seen below.
See also: ScrollContents
Sven2, 2002-04