mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Modernize lua read (part 1): C++ templating insurance (#7394)
* Modernize lua read (part 1): C++ templating assurance Implement the float reader
This commit is contained in:
parent
86b19f2849
commit
180e551c56
9 changed files with 43 additions and 21 deletions
|
@ -898,7 +898,7 @@ int ObjectRef::l_set_yaw(lua_State *L)
|
|||
if (isNaN(L, 2))
|
||||
throw LuaError("ObjectRef::set_yaw: NaN value is not allowed.");
|
||||
|
||||
float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
|
||||
float yaw = readParam<float>(L, 2) * core::RADTODEG;
|
||||
// Do it
|
||||
co->setYaw(yaw);
|
||||
return 0;
|
||||
|
@ -1118,7 +1118,7 @@ int ObjectRef::l_set_look_vertical(lua_State *L)
|
|||
ObjectRef *ref = checkobject(L, 1);
|
||||
PlayerSAO* co = getplayersao(ref);
|
||||
if (co == NULL) return 0;
|
||||
float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
|
||||
float pitch = readParam<float>(L, 2) * core::RADTODEG;
|
||||
// Do it
|
||||
co->setPitchAndSend(pitch);
|
||||
return 1;
|
||||
|
@ -1131,7 +1131,7 @@ int ObjectRef::l_set_look_horizontal(lua_State *L)
|
|||
ObjectRef *ref = checkobject(L, 1);
|
||||
PlayerSAO* co = getplayersao(ref);
|
||||
if (co == NULL) return 0;
|
||||
float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
|
||||
float yaw = readParam<float>(L, 2) * core::RADTODEG;
|
||||
// Do it
|
||||
co->setYawAndSend(yaw);
|
||||
return 1;
|
||||
|
@ -1149,7 +1149,7 @@ int ObjectRef::l_set_look_pitch(lua_State *L)
|
|||
ObjectRef *ref = checkobject(L, 1);
|
||||
PlayerSAO* co = getplayersao(ref);
|
||||
if (co == NULL) return 0;
|
||||
float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
|
||||
float pitch = readParam<float>(L, 2) * core::RADTODEG;
|
||||
// Do it
|
||||
co->setPitchAndSend(pitch);
|
||||
return 1;
|
||||
|
@ -1167,7 +1167,7 @@ int ObjectRef::l_set_look_yaw(lua_State *L)
|
|||
ObjectRef *ref = checkobject(L, 1);
|
||||
PlayerSAO* co = getplayersao(ref);
|
||||
if (co == NULL) return 0;
|
||||
float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
|
||||
float yaw = readParam<float>(L, 2) * core::RADTODEG;
|
||||
// Do it
|
||||
co->setYawAndSend(yaw);
|
||||
return 1;
|
||||
|
@ -1739,7 +1739,7 @@ int ObjectRef::l_override_day_night_ratio(lua_State *L)
|
|||
float ratio = 0.0f;
|
||||
if (!lua_isnil(L, 2)) {
|
||||
do_override = true;
|
||||
ratio = luaL_checknumber(L, 2);
|
||||
ratio = readParam<float>(L, 2);
|
||||
}
|
||||
|
||||
if (!getServer(L)->overrideDayNightRatio(player, do_override, ratio))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue