mirror of
https://github.com/OpenMW/openmw.git
synced 2025-07-01 10:41:37 +00:00
add docs for the new binding
This commit is contained in:
parent
910690c7e5
commit
283be9f4f0
2 changed files with 12 additions and 4 deletions
|
@ -153,7 +153,8 @@ namespace MWLua
|
|||
{ std::move(eventName), LuaUtil::serialize(eventData, context.mSerializer) });
|
||||
};
|
||||
}
|
||||
api["getHeightAt"] = [](float x, float y, sol::object cellOrName) {
|
||||
|
||||
api["getHeightAt"] = [](const osg::Vec3f& pos, sol::object cellOrName) {
|
||||
ESM::RefId worldspace;
|
||||
if (cellOrName.is<GCell>())
|
||||
worldspace = cellOrName.as<GCell>().mStore->getCell()->getWorldSpace();
|
||||
|
@ -167,8 +168,8 @@ namespace MWLua
|
|||
worldspace = ESM::Cell::sDefaultWorldspaceId;
|
||||
|
||||
const float cellSize = ESM::getCellSize(worldspace);
|
||||
int cellX = static_cast<int>(std::floor(x / cellSize));
|
||||
int cellY = static_cast<int>(std::floor(y / cellSize));
|
||||
int cellX = static_cast<int>(std::floor(pos.x() / cellSize));
|
||||
int cellY = static_cast<int>(std::floor(pos.y() / cellSize));
|
||||
|
||||
auto store = MWBase::Environment::get().getESMStore();
|
||||
auto landStore = store->get<ESM::Land>();
|
||||
|
@ -188,7 +189,7 @@ namespace MWLua
|
|||
// If we failed to load data, return the default height
|
||||
return static_cast<float>(ESM::Land::DEFAULT_HEIGHT);
|
||||
}
|
||||
return ESMTerrain::Storage::getHeightAt(landData->mHeights, landData->sLandSize, { x, y, 0 }, cellSize);
|
||||
return ESMTerrain::Storage::getHeightAt(landData->mHeights, landData->sLandSize, pos, cellSize);
|
||||
};
|
||||
|
||||
sol::table readOnlyApi = LuaUtil::makeReadOnly(api);
|
||||
|
|
|
@ -62,6 +62,13 @@
|
|||
-- @param #string setting Setting name
|
||||
-- @return #any
|
||||
|
||||
---
|
||||
-- Get the terrain height at a given location.
|
||||
-- @function [parent=#core] getHeightAt
|
||||
-- @param openmw.util#Vector3 position
|
||||
-- @param #any cellOrName (optional) cell or cell name in their exterior world space to query
|
||||
-- @return #number
|
||||
|
||||
---
|
||||
-- Return l10n formatting function for the given context.
|
||||
-- Localisation files (containing the message names and translations) should be stored in
|
||||
|
|
Loading…
Reference in a new issue