mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
RealBadAngel's patch which allows the lua api to read pressed player keys. This should make it possible to change the player's animation based on what he is doing
Correct lua api version number Always update animations and attachments after the entity is added to scene client side. Fixes animations not being applied in client initialization for some reason. Attachments should be re-tested now just to be safe. Fix a segmentation fault caused by reaching materials that didn't exist in a loop for setting texture
This commit is contained in:
parent
756db8174a
commit
3d1c481f0b
9 changed files with 165 additions and 69 deletions
|
@ -2369,7 +2369,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
|
||||
if(command == TOSERVER_PLAYERPOS)
|
||||
{
|
||||
if(datasize < 2+12+12+4+4)
|
||||
if(datasize < 2+12+12+4+4+4)
|
||||
return;
|
||||
|
||||
u32 start = 0;
|
||||
|
@ -2377,6 +2377,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
v3s32 ss = readV3S32(&data[start+2+12]);
|
||||
f32 pitch = (f32)readS32(&data[2+12+12]) / 100.0;
|
||||
f32 yaw = (f32)readS32(&data[2+12+12+4]) / 100.0;
|
||||
u32 keyPressed = (u32)readU32(&data[2+12+12+4+4]);
|
||||
v3f position((f32)ps.X/100., (f32)ps.Y/100., (f32)ps.Z/100.);
|
||||
v3f speed((f32)ss.X/100., (f32)ss.Y/100., (f32)ss.Z/100.);
|
||||
pitch = wrapDegrees(pitch);
|
||||
|
@ -2386,6 +2387,16 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
player->setSpeed(speed);
|
||||
player->setPitch(pitch);
|
||||
player->setYaw(yaw);
|
||||
player->keyPressed=keyPressed;
|
||||
player->control.up = (bool)(keyPressed&1);
|
||||
player->control.down = (bool)(keyPressed&2);
|
||||
player->control.left = (bool)(keyPressed&4);
|
||||
player->control.right = (bool)(keyPressed&8);
|
||||
player->control.jump = (bool)(keyPressed&16);
|
||||
player->control.aux1 = (bool)(keyPressed&32);
|
||||
player->control.sneak = (bool)(keyPressed&64);
|
||||
player->control.LMB = (bool)(keyPressed&128);
|
||||
player->control.RMB = (bool)(keyPressed&256);
|
||||
|
||||
/*infostream<<"Server::ProcessData(): Moved player "<<peer_id<<" to "
|
||||
<<"("<<position.X<<","<<position.Y<<","<<position.Z<<")"
|
||||
|
@ -3166,6 +3177,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
}
|
||||
|
||||
} // action == 4
|
||||
|
||||
|
||||
/*
|
||||
Catch invalid actions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue