mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-16 17:42:31 +00:00
Added scale property and setScale function
This commit is contained in:
parent
95522de8e8
commit
41a2c82f93
@ -157,6 +157,8 @@ namespace MWLua
|
|||||||
});
|
});
|
||||||
objectT["position"] = sol::readonly_property(
|
objectT["position"] = sol::readonly_property(
|
||||||
[](const ObjectT& o) -> osg::Vec3f { return o.ptr().getRefData().getPosition().asVec3(); });
|
[](const ObjectT& o) -> osg::Vec3f { return o.ptr().getRefData().getPosition().asVec3(); });
|
||||||
|
objectT["scale"]
|
||||||
|
= sol::readonly_property([](const ObjectT& o) -> float { return o.ptr().getCellRef().getScale(); });
|
||||||
objectT["rotation"] = sol::readonly_property(
|
objectT["rotation"] = sol::readonly_property(
|
||||||
[](const ObjectT& o) -> osg::Vec3f { return o.ptr().getRefData().getPosition().asRotationVec3(); });
|
[](const ObjectT& o) -> osg::Vec3f { return o.ptr().getRefData().getPosition().asRotationVec3(); });
|
||||||
objectT["startingPosition"] = sol::readonly_property(
|
objectT["startingPosition"] = sol::readonly_property(
|
||||||
@ -278,6 +280,9 @@ namespace MWLua
|
|||||||
|
|
||||||
if constexpr (std::is_same_v<ObjectT, GObject>)
|
if constexpr (std::is_same_v<ObjectT, GObject>)
|
||||||
{ // Only for global scripts
|
{ // Only for global scripts
|
||||||
|
objectT["setScale"] = [](const GObject& object, float scale) {
|
||||||
|
MWBase::Environment::get().getWorld()->scaleObject(object.ptr(), scale);
|
||||||
|
};
|
||||||
objectT["addScript"] = [context](const GObject& object, std::string_view path, sol::object initData) {
|
objectT["addScript"] = [context](const GObject& object, std::string_view path, sol::object initData) {
|
||||||
const LuaUtil::ScriptsConfiguration& cfg = context.mLua->getConfiguration();
|
const LuaUtil::ScriptsConfiguration& cfg = context.mLua->getConfiguration();
|
||||||
std::optional<int> scriptId = cfg.findId(path);
|
std::optional<int> scriptId = cfg.findId(path);
|
||||||
|
@ -110,6 +110,7 @@
|
|||||||
-- @field #string id A unique id of this object (not record id), can be used as a key in a table.
|
-- @field #string id A unique id of this object (not record id), can be used as a key in a table.
|
||||||
-- @field #boolean enabled Whether the object is enabled or disabled. Global scripts can set the value. Items in containers or inventories can't be disabled.
|
-- @field #boolean enabled Whether the object is enabled or disabled. Global scripts can set the value. Items in containers or inventories can't be disabled.
|
||||||
-- @field openmw.util#Vector3 position Object position.
|
-- @field openmw.util#Vector3 position Object position.
|
||||||
|
-- @field #number scale Object scale.
|
||||||
-- @field openmw.util#Vector3 rotation Object rotation (ZXY order).
|
-- @field openmw.util#Vector3 rotation Object rotation (ZXY order).
|
||||||
-- @field openmw.util#Vector3 startingPosition The object original position
|
-- @field openmw.util#Vector3 startingPosition The object original position
|
||||||
-- @field openmw.util#Vector3 startingRotation The object original rotation
|
-- @field openmw.util#Vector3 startingRotation The object original rotation
|
||||||
@ -168,6 +169,13 @@
|
|||||||
-- @param self
|
-- @param self
|
||||||
-- @param #string scriptPath Path to the script in OpenMW virtual filesystem.
|
-- @param #string scriptPath Path to the script in OpenMW virtual filesystem.
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Sets the object's scale.
|
||||||
|
-- Can be called only from a global script.
|
||||||
|
-- @function [parent=#GameObject] setScale
|
||||||
|
-- @param self
|
||||||
|
-- @param #number scale Scale desired in game.
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Moves object to given cell and position.
|
-- Moves object to given cell and position.
|
||||||
-- Can be called only from a global script.
|
-- Can be called only from a global script.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user