diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index 0d954e7cdb..3978348619 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -1472,6 +1472,7 @@ declare global { occupiedQuadrants: number; isGhost: boolean; isHidden: boolean; /** Take caution when changing this field, it may invalidate TileElements you have stored in your script. */ + owner: number; } interface SurfaceElement extends BaseTileElement { diff --git a/src/openrct2/scripting/bindings/world/ScTileElement.cpp b/src/openrct2/scripting/bindings/world/ScTileElement.cpp index 4eb6f23553..5ef22ad0a1 100644 --- a/src/openrct2/scripting/bindings/world/ScTileElement.cpp +++ b/src/openrct2/scripting/bindings/world/ScTileElement.cpp @@ -2033,6 +2033,20 @@ namespace OpenRCT2::Scripting } } + DukValue ScTileElement::owner_get() const + { + auto& scriptEngine = GetContext()->GetScriptEngine(); + auto* ctx = scriptEngine.GetContext(); + duk_push_uint(ctx, _element->GetOwner()); + return DukValue::take_from_stack(ctx); + } + + void ScTileElement::owner_set(uint8_t value) + { + ThrowIfGameStateNotMutable(); + _element->SetOwner(value); + } + void ScTileElement::Invalidate() { MapInvalidateTileFull(_coords); @@ -2051,6 +2065,7 @@ namespace OpenRCT2::Scripting ctx, &ScTileElement::occupiedQuadrants_get, &ScTileElement::occupiedQuadrants_set, "occupiedQuadrants"); dukglue_register_property(ctx, &ScTileElement::isGhost_get, &ScTileElement::isGhost_set, "isGhost"); dukglue_register_property(ctx, &ScTileElement::isHidden_get, &ScTileElement::isHidden_set, "isHidden"); + dukglue_register_property(ctx, &ScTileElement::owner_get, &ScTileElement::owner_set, "owner"); // Track | Small Scenery | Wall | Entrance | Large Scenery | Banner dukglue_register_property(ctx, &ScTileElement::direction_get, &ScTileElement::direction_set, "direction"); diff --git a/src/openrct2/scripting/bindings/world/ScTileElement.hpp b/src/openrct2/scripting/bindings/world/ScTileElement.hpp index f7bba6416a..3a48a23e06 100644 --- a/src/openrct2/scripting/bindings/world/ScTileElement.hpp +++ b/src/openrct2/scripting/bindings/world/ScTileElement.hpp @@ -202,6 +202,9 @@ namespace OpenRCT2::Scripting DukValue direction_get() const; void direction_set(uint8_t value); + DukValue owner_get() const; + void owner_set(uint8_t value); + void Invalidate(); public: