Home API Manuals About Forum
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

GetUserStatic

Returns a user static by its ID: the static item itself and the world it was added to.

ID — identifier of the user static, as returned by AddUserStatic (Python: CreateUserStatic).

Returns True if a user static with this ID exists. Returns False if the ID was removed by RemoveUserStatic, was never issued, or if UO data is not loaded; StaticItem and WorldNum are then zeroed.

IDs are shared by all worlds and grow by one with every new static. Removed IDs leave holes, and only ClearUserStatics resets the numbering. To walk all user statics, iterate from 0 to GetUserStaticsHigh and skip the IDs for which GetUserStatic returns False.

In Python the method returns a tuple (found, item, world_num).

Возвращает пользовательский статик по его идентификатору: сам статик-объект и мир, в который он добавлен.

ID — идентификатор пользовательского статика, возвращённый AddUserStatic (Python: CreateUserStatic).

Возвращает True, если статик с таким ID существует. Возвращает False, если ID удалён через RemoveUserStatic, ещё не выдавался или данные UO не загружены; StaticItem и WorldNum при этом обнуляются.

ID общие для всех миров и растут на единицу с каждым новым статиком. Удалённые ID остаются «дырами», нумерацию сбрасывает только ClearUserStatics. Чтобы перебрать все пользовательские статики, идите от 0 до GetUserStaticsHigh и пропускайте ID, для которых GetUserStatic вернул False.

В Python метод возвращает кортеж (found, item, world_num).

Pascal

function GetUserStatic(ID: Integer; var StaticItem: TStaticItem; var WorldNum: Byte): Boolean;

Parameters:

  • ID — user static ID.
  • StaticItem — receives the static item.
  • WorldNum — receives the world/facet number the static was added to.

Type definition:

TStaticItem = packed record
  Tile: Word;
  X: Word;
  Y: Word;
  Z: ShortInt;
  Color: Word;
end;

Python

def GetUserStatic(StaticID: int) -> tuple[bool, UserStaticItem, int]: ...

Pascal Example

var
  i: Integer;
  Item: TStaticItem;
  World: Byte;
begin
  for i := 0 to GetUserStaticsHigh do
    if GetUserStatic(i, Item, World) then
      AddToSystemJournal(Format('ID %d: tile $%.4x at %d, %d, %d (world %d)',
        [i, Item.Tile, Item.X, Item.Y, Item.Z, World]));
end.

Python Example

for sid in range(GetUserStaticsHigh() + 1):
    found, item, world = GetUserStatic(sid)
    if found:
        AddToSystemJournal(f'ID {sid}: tile {item.Tile:#06x} at {item.X}, {item.Y}, {item.Z} (world {world})')

See Also

GetUserStaticsHigh, AddUserStatic, RemoveUserStatic, ClearUserStatics