mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 21:40:03 +00:00
Merge branch 'set_scale' into 'master'
Allow Lua to set and get GameObject's in game scale See merge request OpenMW/openmw!3114
This commit is contained in:
commit
3fcf9dc1d2
@ -164,6 +164,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(
|
||||||
@ -285,6 +287,10 @@ 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"] = [context](const GObject& object, float scale) {
|
||||||
|
context.mLuaManager->addAction(
|
||||||
|
[object, 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);
|
||||||
|
@ -151,6 +151,7 @@
|
|||||||
-- @field #string contentFile Lower cased file name of the content file that defines this object; nil for dynamically created objects.
|
-- @field #string contentFile Lower cased file name of the content file that defines this object; nil for dynamically created objects.
|
||||||
-- @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
|
||||||
@ -209,6 +210,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