forked from Mirrorlandia_minetest/minetest
ObjectRef: Re-add legacy code for set_physics_override (#10585)
These arguments are used at least by MTG beds and homedecor_common. A deprecation warning is shown to safely remove it in a future release.
This commit is contained in:
parent
97aefe9b81
commit
fca4db4184
@ -1413,20 +1413,34 @@ int ObjectRef::l_set_physics_override(lua_State *L)
|
|||||||
if (playersao == nullptr)
|
if (playersao == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
luaL_checktype(L, 2, LUA_TTABLE);
|
if (lua_istable(L, 2)) {
|
||||||
playersao->m_physics_override_speed = getfloatfield_default(
|
bool modified = false;
|
||||||
L, 2, "speed", playersao->m_physics_override_speed);
|
modified |= getfloatfield(L, 2, "speed", playersao->m_physics_override_speed);
|
||||||
playersao->m_physics_override_jump = getfloatfield_default(
|
modified |= getfloatfield(L, 2, "jump", playersao->m_physics_override_jump);
|
||||||
L, 2, "jump", playersao->m_physics_override_jump);
|
modified |= getfloatfield(L, 2, "gravity", playersao->m_physics_override_gravity);
|
||||||
playersao->m_physics_override_gravity = getfloatfield_default(
|
modified |= getboolfield(L, 2, "sneak", playersao->m_physics_override_sneak);
|
||||||
L, 2, "gravity", playersao->m_physics_override_gravity);
|
modified |= getboolfield(L, 2, "sneak_glitch", playersao->m_physics_override_sneak_glitch);
|
||||||
playersao->m_physics_override_sneak = getboolfield_default(
|
modified |= getboolfield(L, 2, "new_move", playersao->m_physics_override_new_move);
|
||||||
L, 2, "sneak", playersao->m_physics_override_sneak);
|
if (modified)
|
||||||
playersao->m_physics_override_sneak_glitch = getboolfield_default(
|
playersao->m_physics_override_sent = false;
|
||||||
L, 2, "sneak_glitch", playersao->m_physics_override_sneak_glitch);
|
} else {
|
||||||
playersao->m_physics_override_new_move = getboolfield_default(
|
// old, non-table format
|
||||||
L, 2, "new_move", playersao->m_physics_override_new_move);
|
// TODO: Remove this code after version 5.4.0
|
||||||
playersao->m_physics_override_sent = false;
|
log_deprecated(L, "Deprecated use of set_physics_override(num, num, num)");
|
||||||
|
|
||||||
|
if (!lua_isnil(L, 2)) {
|
||||||
|
playersao->m_physics_override_speed = lua_tonumber(L, 2);
|
||||||
|
playersao->m_physics_override_sent = false;
|
||||||
|
}
|
||||||
|
if (!lua_isnil(L, 3)) {
|
||||||
|
playersao->m_physics_override_jump = lua_tonumber(L, 3);
|
||||||
|
playersao->m_physics_override_sent = false;
|
||||||
|
}
|
||||||
|
if (!lua_isnil(L, 4)) {
|
||||||
|
playersao->m_physics_override_gravity = lua_tonumber(L, 4);
|
||||||
|
playersao->m_physics_override_sent = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user