return 1;
}
-int LuaLocalPlayer::l_get_liquid_viscosity(lua_State *L)
+int LuaLocalPlayer::l_get_move_resistance(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
- lua_pushinteger(L, player->liquid_viscosity);
+ lua_pushinteger(L, player->move_resistance);
return 1;
}
};
lua_createtable(L, 0, 12);
- set("up", c.up);
- set("down", c.down);
- set("left", c.left);
- set("right", c.right);
- set("jump", c.jump);
- set("aux1", c.aux1);
+ set("jump", c.jump);
+ set("aux1", c.aux1);
set("sneak", c.sneak);
- set("zoom", c.zoom);
- set("LMB", c.LMB);
- set("RMB", c.RMB);
+ set("zoom", c.zoom);
+ set("dig", c.dig);
+ set("place", c.place);
+ // Player movement in polar coordinates and non-binary speed
+ set("movement_speed", c.movement_speed);
+ set("movement_direction", c.movement_direction);
+ // Provide direction keys to ensure compatibility
+ set("up", player->keyPressed & (1 << 0)); // Up, down, left, and right were removed in favor of
+ set("down", player->keyPressed & (1 << 1)); // analog direction indicators and are therefore not
+ set("left", player->keyPressed & (1 << 2)); // available as booleans anymore. The corresponding values
+ set("right", player->keyPressed & (1 << 3)); // can still be read from the keyPressed bits though.
return 1;
}
if (!element)
return 0;
+ HudElementStat stat;
void *unused;
- read_hud_change(L, element, &unused);
+ bool ok = read_hud_change(L, stat, element, &unused);
- lua_pushboolean(L, true);
+ lua_pushboolean(L, ok);
return 1;
}
lua_pop(L, 1); // Drop metatable
- luaL_openlib(L, 0, methods, 0); // fill methodtable
+ luaL_register(L, nullptr, methods); // fill methodtable
lua_pop(L, 1); // Drop methodtable
}
luamethod(LuaLocalPlayer, is_touching_ground),
luamethod(LuaLocalPlayer, is_in_liquid),
luamethod(LuaLocalPlayer, is_in_liquid_stable),
- luamethod(LuaLocalPlayer, get_liquid_viscosity),
luamethod(LuaLocalPlayer, is_climbing),
luamethod(LuaLocalPlayer, swimming_vertical),
luamethod(LuaLocalPlayer, get_physics_override),
luamethod(LuaLocalPlayer, hud_change),
luamethod(LuaLocalPlayer, hud_get),
+ luamethod(LuaLocalPlayer, get_move_resistance),
+
{0, 0}
};