Skip to content

Commit

Permalink
LUA Update SetPositionToPoint for Player
Browse files Browse the repository at this point in the history
  • Loading branch information
pinguin999 committed Jul 23, 2024
1 parent 1efb96f commit f9fd866
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ void Game::setupLuaFunctions()

if (position)
{
if (std::shared_ptr<Player> p = std::dynamic_pointer_cast<Player>(obj); p != nullptr)
{
p->setPosition(position.value());
p->addTargetPositionImmediately(position.value(), (*lua_state)["pass"]);
}
obj->setPosition(position.value());
std::string lua_object = getLuaPath(obj->getId());
lua_state->script(lua_object + ".x = " + std::to_string(position->x) + "");
Expand All @@ -490,6 +495,13 @@ void Game::setupLuaFunctions()
auto position = getPointPosition(shared_from_this(), point_name);
if (position)
{

if (std::shared_ptr<Player> p = std::dynamic_pointer_cast<Player>(obj); p != nullptr)
{
p->setPosition(position.value());
p->stop_walking();
p->addTargetPositionImmediately(position.value(), (*lua_state)["pass"]);
}
obj->setPosition(position.value());
std::string lua_object = getLuaPath(obj->getId());
lua_state->script(lua_object + ".x = " + std::to_string(position->x) + "");
Expand Down

0 comments on commit f9fd866

Please sign in to comment.