@@ -64,6 +64,53 @@ static const luaL_Reg player_position_methods[] =
6464
6565// ----------------------------------------------------------------------------
6666
67+ // $Game.LocalPlayer.Velocity
68+
69+ /*
70+ - Gets local player velocity
71+ ## return: number
72+ ## return: number
73+ ## return: number
74+ ### Game.LocalPlayer.Velocity.get
75+ */
76+ static int l_Player_Velocity_get (lua_State *L)
77+ {
78+ float x = Minecraft::GetVelocityX ();
79+ float y = Minecraft::GetVelocityY ();
80+ float z = Minecraft::GetVelocityZ ();
81+ lua_pushnumber (L, x);
82+ lua_pushnumber (L, y);
83+ lua_pushnumber (L, z);
84+ return 1 ;
85+ }
86+
87+ /*
88+ - Sets player velocity
89+ ## x: number
90+ ## y: number
91+ ## z: number
92+ ### Game.LocalPlayer.Velocity.set
93+ */
94+ static int l_Player_Velocity_set (lua_State *L)
95+ {
96+ float x = luaL_checknumber (L, 1 );
97+ float y = luaL_checknumber (L, 2 );
98+ float z = luaL_checknumber (L, 3 );
99+ Minecraft::SetVelocityX (x);
100+ Minecraft::SetVelocityY (y);
101+ Minecraft::SetVelocityZ (z);
102+ return 0 ;
103+ }
104+
105+ static const luaL_Reg player_velocity_methods[] =
106+ {
107+ {" get" , l_Player_Velocity_get},
108+ {" set" , l_Player_Velocity_set},
109+ {NULL , NULL }
110+ };
111+
112+ // ----------------------------------------------------------------------------
113+
67114/*
68115=Game.LocalPlayer.OnGround = false
69116=Game.LocalPlayer.Sneaking = false
@@ -293,6 +340,7 @@ bool Core::Game::RegisterLocalPlayerModule(lua_State *L)
293340 lua_newtable (L); // LocalPlayer
294341
295342 luaC_register_field (L, player_position_methods, " Position" );
343+ luaC_register_field (L, player_velocity_methods, " Velocity" );
296344 Core::Game::LocalPlayer::RegisterCameraModule (L);
297345 Core::Game::LocalPlayer::RegisterInventoryModule (L);
298346
0 commit comments