mirror of https://github.com/minetest/minetest.git
Lua API: Renamed argument save_playback_pos in method set_animation
save_playback_pos => restart
This commit is contained in:
parent
2ee04aa3cd
commit
af10f26bc3
|
@ -2628,7 +2628,7 @@ This is basically a reference to a C++ `ServerActiveObject`
|
||||||
* `set_wielded_item(item)`: replaces the wielded item, returns `true` if successful
|
* `set_wielded_item(item)`: replaces the wielded item, returns `true` if successful
|
||||||
* `set_armor_groups({group1=rating, group2=rating, ...})`
|
* `set_armor_groups({group1=rating, group2=rating, ...})`
|
||||||
* `get_armor_groups()`: returns a table with the armor group ratings
|
* `get_armor_groups()`: returns a table with the armor group ratings
|
||||||
* `set_animation({x=1,y=1}, frame_speed=15, frame_blend=0, frame_loop=true, save_playback_pos=true)`
|
* `set_animation({x=1,y=1}, frame_speed=15, frame_blend=0, frame_loop=true, restart=false)`
|
||||||
* `get_animation()`: returns range, frame_speed, frame_blend and frame_loop
|
* `get_animation()`: returns range, frame_speed, frame_blend and frame_loop
|
||||||
* `set_attach(parent, bone, position, rotation)`
|
* `set_attach(parent, bone, position, rotation)`
|
||||||
* `bone`: string
|
* `bone`: string
|
||||||
|
|
|
@ -566,7 +566,7 @@ GenericCAO::GenericCAO(IGameDef *gamedef, ClientEnvironment *env):
|
||||||
m_animation_speed(15),
|
m_animation_speed(15),
|
||||||
m_animation_blend(0),
|
m_animation_blend(0),
|
||||||
m_animation_loop(true),
|
m_animation_loop(true),
|
||||||
m_animation_save_playback_pos(true),
|
m_animation_restart(true),
|
||||||
m_bone_position(std::map<std::string, core::vector2d<v3f> >()),
|
m_bone_position(std::map<std::string, core::vector2d<v3f> >()),
|
||||||
m_attachment_bone(""),
|
m_attachment_bone(""),
|
||||||
m_attachment_position(v3f(0,0,0)),
|
m_attachment_position(v3f(0,0,0)),
|
||||||
|
@ -1493,22 +1493,22 @@ void GenericCAO::updateAnimation()
|
||||||
|
|
||||||
if (m_animated_meshnode->getStartFrame() == m_animation_range.X &&
|
if (m_animated_meshnode->getStartFrame() == m_animation_range.X &&
|
||||||
m_animated_meshnode->getEndFrame() == m_animation_range.Y) {
|
m_animated_meshnode->getEndFrame() == m_animation_range.Y) {
|
||||||
if (m_animation_save_playback_pos) {
|
if (m_animation_restart) {
|
||||||
|
m_animated_meshnode->setCurrentFrame(m_animation_range.X);
|
||||||
|
} else {
|
||||||
f32 current_frame = m_animated_meshnode->getFrameNr();
|
f32 current_frame = m_animated_meshnode->getFrameNr();
|
||||||
m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
|
m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
|
||||||
m_animated_meshnode->setCurrentFrame(current_frame);
|
m_animated_meshnode->setCurrentFrame(current_frame);
|
||||||
} else {
|
|
||||||
m_animated_meshnode->setCurrentFrame(m_animation_range.X);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m_animation_save_playback_pos) {
|
if (m_animation_restart) {
|
||||||
|
m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
|
||||||
|
m_animated_meshnode->setCurrentFrame(m_animation_range.X);
|
||||||
|
} else {
|
||||||
f32 new_animation_pos = m_animated_meshnode->getFrameNr() - m_animated_meshnode->getStartFrame();
|
f32 new_animation_pos = m_animated_meshnode->getFrameNr() - m_animated_meshnode->getStartFrame();
|
||||||
f32 new_animation_length = m_animation_range.Y - m_animation_range.X;
|
f32 new_animation_length = m_animation_range.Y - m_animation_range.X;
|
||||||
m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
|
m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
|
||||||
m_animated_meshnode->setCurrentFrame(m_animation_range.X + fmod(new_animation_pos, new_animation_length));
|
m_animated_meshnode->setCurrentFrame(m_animation_range.X + fmod(new_animation_pos, new_animation_length));
|
||||||
} else {
|
|
||||||
m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
|
|
||||||
m_animated_meshnode->setCurrentFrame(m_animation_range.X);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_animated_meshnode->getAnimationSpeed() != m_animation_speed)
|
if (m_animated_meshnode->getAnimationSpeed() != m_animation_speed)
|
||||||
|
@ -1689,7 +1689,7 @@ void GenericCAO::processMessage(const std::string &data)
|
||||||
m_animation_blend = readF1000(is);
|
m_animation_blend = readF1000(is);
|
||||||
// these are sent inverted so we get true when the server sends nothing
|
// these are sent inverted so we get true when the server sends nothing
|
||||||
m_animation_loop = !readU8(is);
|
m_animation_loop = !readU8(is);
|
||||||
m_animation_save_playback_pos = !readU8(is);
|
m_animation_restart = !readU8(is);
|
||||||
updateAnimation();
|
updateAnimation();
|
||||||
} else {
|
} else {
|
||||||
LocalPlayer *player = m_env->getLocalPlayer();
|
LocalPlayer *player = m_env->getLocalPlayer();
|
||||||
|
@ -1700,7 +1700,7 @@ void GenericCAO::processMessage(const std::string &data)
|
||||||
m_animation_blend = readF1000(is);
|
m_animation_blend = readF1000(is);
|
||||||
// these are sent inverted so we get true when the server sends nothing
|
// these are sent inverted so we get true when the server sends nothing
|
||||||
m_animation_loop = !readU8(is);
|
m_animation_loop = !readU8(is);
|
||||||
m_animation_save_playback_pos = !readU8(is);
|
m_animation_restart = !readU8(is);
|
||||||
}
|
}
|
||||||
// update animation only if local animations present
|
// update animation only if local animations present
|
||||||
// and received animation is unknown (except idle animation)
|
// and received animation is unknown (except idle animation)
|
||||||
|
|
|
@ -90,7 +90,7 @@ private:
|
||||||
int m_animation_speed;
|
int m_animation_speed;
|
||||||
int m_animation_blend;
|
int m_animation_blend;
|
||||||
bool m_animation_loop;
|
bool m_animation_loop;
|
||||||
bool m_animation_save_playback_pos;
|
bool m_animation_restart;
|
||||||
std::map<std::string, core::vector2d<v3f> > m_bone_position; // stores position and rotation for each bone name
|
std::map<std::string, core::vector2d<v3f> > m_bone_position; // stores position and rotation for each bone name
|
||||||
std::string m_attachment_bone;
|
std::string m_attachment_bone;
|
||||||
v3f m_attachment_position;
|
v3f m_attachment_position;
|
||||||
|
|
|
@ -136,7 +136,7 @@ LuaEntitySAO::LuaEntitySAO(ServerEnvironment *env, v3f pos,
|
||||||
m_animation_speed(0),
|
m_animation_speed(0),
|
||||||
m_animation_blend(0),
|
m_animation_blend(0),
|
||||||
m_animation_loop(true),
|
m_animation_loop(true),
|
||||||
m_animation_save_playback_pos(true),
|
m_animation_restart(true),
|
||||||
m_animation_sent(false),
|
m_animation_sent(false),
|
||||||
m_bone_position_sent(false),
|
m_bone_position_sent(false),
|
||||||
m_attachment_parent_id(0),
|
m_attachment_parent_id(0),
|
||||||
|
@ -338,7 +338,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
|
||||||
if(m_animation_sent == false){
|
if(m_animation_sent == false){
|
||||||
m_animation_sent = true;
|
m_animation_sent = true;
|
||||||
std::string str = gob_cmd_update_animation(
|
std::string str = gob_cmd_update_animation(
|
||||||
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop, m_animation_save_playback_pos);
|
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop, m_animation_restart);
|
||||||
// create message and add to list
|
// create message and add to list
|
||||||
ActiveObjectMessage aom(getId(), true, str);
|
ActiveObjectMessage aom(getId(), true, str);
|
||||||
m_messages_out.push(aom);
|
m_messages_out.push(aom);
|
||||||
|
@ -381,7 +381,7 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
|
||||||
os<<serializeLongString(getPropertyPacket()); // message 1
|
os<<serializeLongString(getPropertyPacket()); // message 1
|
||||||
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
|
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
|
||||||
os<<serializeLongString(gob_cmd_update_animation(
|
os<<serializeLongString(gob_cmd_update_animation(
|
||||||
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop, m_animation_save_playback_pos)); // 3
|
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop, m_animation_restart)); // 3
|
||||||
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
|
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
|
||||||
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
|
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
|
||||||
}
|
}
|
||||||
|
@ -549,13 +549,13 @@ ItemGroupList LuaEntitySAO::getArmorGroups()
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaEntitySAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend,
|
void LuaEntitySAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend,
|
||||||
bool frame_loop, bool save_playback_pos)
|
bool frame_loop, bool restart)
|
||||||
{
|
{
|
||||||
m_animation_range = frame_range;
|
m_animation_range = frame_range;
|
||||||
m_animation_speed = frame_speed;
|
m_animation_speed = frame_speed;
|
||||||
m_animation_blend = frame_blend;
|
m_animation_blend = frame_blend;
|
||||||
m_animation_loop = frame_loop;
|
m_animation_loop = frame_loop;
|
||||||
m_animation_save_playback_pos = save_playback_pos;
|
m_animation_restart = restart;
|
||||||
m_animation_sent = false;
|
m_animation_sent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,7 +862,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
|
||||||
os<<serializeLongString(getPropertyPacket()); // message 1
|
os<<serializeLongString(getPropertyPacket()); // message 1
|
||||||
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
|
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
|
||||||
os<<serializeLongString(gob_cmd_update_animation(
|
os<<serializeLongString(gob_cmd_update_animation(
|
||||||
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop, m_animation_save_playback_pos)); // 3
|
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop, m_animation_restart)); // 3
|
||||||
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
|
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
|
||||||
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
|
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
|
||||||
}
|
}
|
||||||
|
@ -1002,7 +1002,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
|
||||||
if(m_animation_sent == false){
|
if(m_animation_sent == false){
|
||||||
m_animation_sent = true;
|
m_animation_sent = true;
|
||||||
std::string str = gob_cmd_update_animation(
|
std::string str = gob_cmd_update_animation(
|
||||||
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop, m_animation_save_playback_pos);
|
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop, m_animation_restart);
|
||||||
// create message and add to list
|
// create message and add to list
|
||||||
ActiveObjectMessage aom(getId(), true, str);
|
ActiveObjectMessage aom(getId(), true, str);
|
||||||
m_messages_out.push(aom);
|
m_messages_out.push(aom);
|
||||||
|
@ -1194,14 +1194,14 @@ ItemGroupList PlayerSAO::getArmorGroups()
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerSAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend,
|
void PlayerSAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend,
|
||||||
bool frame_loop, bool save_playback_pos)
|
bool frame_loop, bool restart)
|
||||||
{
|
{
|
||||||
// store these so they can be updated to clients
|
// store these so they can be updated to clients
|
||||||
m_animation_range = frame_range;
|
m_animation_range = frame_range;
|
||||||
m_animation_speed = frame_speed;
|
m_animation_speed = frame_speed;
|
||||||
m_animation_blend = frame_blend;
|
m_animation_blend = frame_blend;
|
||||||
m_animation_loop = frame_loop;
|
m_animation_loop = frame_loop;
|
||||||
m_animation_save_playback_pos = save_playback_pos;
|
m_animation_restart = restart;
|
||||||
m_animation_sent = false;
|
m_animation_sent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
s16 getHP() const;
|
s16 getHP() const;
|
||||||
void setArmorGroups(const ItemGroupList &armor_groups);
|
void setArmorGroups(const ItemGroupList &armor_groups);
|
||||||
ItemGroupList getArmorGroups();
|
ItemGroupList getArmorGroups();
|
||||||
void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop, bool save_playback_pos);
|
void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop, bool restart);
|
||||||
void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop);
|
void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop);
|
||||||
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
|
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
|
||||||
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
|
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
|
||||||
|
@ -110,7 +110,7 @@ private:
|
||||||
float m_animation_speed;
|
float m_animation_speed;
|
||||||
float m_animation_blend;
|
float m_animation_blend;
|
||||||
bool m_animation_loop;
|
bool m_animation_loop;
|
||||||
bool m_animation_save_playback_pos;
|
bool m_animation_restart;
|
||||||
bool m_animation_sent;
|
bool m_animation_sent;
|
||||||
|
|
||||||
std::map<std::string, core::vector2d<v3f> > m_bone_position;
|
std::map<std::string, core::vector2d<v3f> > m_bone_position;
|
||||||
|
@ -203,7 +203,7 @@ public:
|
||||||
void setBreath(u16 breath);
|
void setBreath(u16 breath);
|
||||||
void setArmorGroups(const ItemGroupList &armor_groups);
|
void setArmorGroups(const ItemGroupList &armor_groups);
|
||||||
ItemGroupList getArmorGroups();
|
ItemGroupList getArmorGroups();
|
||||||
void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop, bool save_playback_pos);
|
void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop, bool restart);
|
||||||
void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop);
|
void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop);
|
||||||
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
|
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
|
||||||
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
|
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
|
||||||
|
@ -320,7 +320,7 @@ private:
|
||||||
float m_animation_speed;
|
float m_animation_speed;
|
||||||
float m_animation_blend;
|
float m_animation_blend;
|
||||||
bool m_animation_loop;
|
bool m_animation_loop;
|
||||||
bool m_animation_save_playback_pos;
|
bool m_animation_restart;
|
||||||
bool m_animation_sent;
|
bool m_animation_sent;
|
||||||
|
|
||||||
std::map<std::string, core::vector2d<v3f> > m_bone_position; // Stores position and rotation for each bone name
|
std::map<std::string, core::vector2d<v3f> > m_bone_position; // Stores position and rotation for each bone name
|
||||||
|
|
|
@ -134,7 +134,7 @@ std::string gob_cmd_update_physics_override(float physics_override_speed, float
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend,
|
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend,
|
||||||
bool frame_loop, bool save_playback_pos)
|
bool frame_loop, bool restart)
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
// command
|
// command
|
||||||
|
@ -145,7 +145,7 @@ std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_
|
||||||
writeF1000(os, frame_blend);
|
writeF1000(os, frame_blend);
|
||||||
// these are sent inverted so we get true when the server sends nothing
|
// these are sent inverted so we get true when the server sends nothing
|
||||||
writeU8(os, !frame_loop);
|
writeU8(os, !frame_loop);
|
||||||
writeU8(os, !save_playback_pos);
|
writeU8(os, !restart);
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ std::string gob_cmd_update_physics_override(float physics_override_speed,
|
||||||
float physics_override_jump, float physics_override_gravity, bool sneak, bool sneak_glitch);
|
float physics_override_jump, float physics_override_gravity, bool sneak, bool sneak_glitch);
|
||||||
|
|
||||||
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend,
|
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend,
|
||||||
bool frame_loop, bool save_playback_pos);
|
bool frame_loop, bool restart);
|
||||||
|
|
||||||
std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rotation);
|
std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rotation);
|
||||||
|
|
||||||
|
|
|
@ -457,7 +457,7 @@ int ObjectRef::l_get_physics_override(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set_animation(self, frame_range, frame_speed, frame_blend, frame_loop, save_playback_pos)
|
// set_animation(self, frame_range, frame_speed, frame_blend, frame_loop, restart)
|
||||||
int ObjectRef::l_set_animation(lua_State *L)
|
int ObjectRef::l_set_animation(lua_State *L)
|
||||||
{
|
{
|
||||||
NO_MAP_LOCK_REQUIRED;
|
NO_MAP_LOCK_REQUIRED;
|
||||||
|
@ -477,10 +477,10 @@ int ObjectRef::l_set_animation(lua_State *L)
|
||||||
bool frame_loop = true;
|
bool frame_loop = true;
|
||||||
if (lua_isboolean(L, 5))
|
if (lua_isboolean(L, 5))
|
||||||
frame_loop = lua_toboolean(L, 5);
|
frame_loop = lua_toboolean(L, 5);
|
||||||
bool save_playback_pos = true;
|
bool restart = false;
|
||||||
if (lua_isboolean(L, 6))
|
if (lua_isboolean(L, 6))
|
||||||
save_playback_pos = lua_toboolean(L, 6);
|
restart = lua_toboolean(L, 6);
|
||||||
co->setAnimation(frames, frame_speed, frame_blend, frame_loop, save_playback_pos);
|
co->setAnimation(frames, frame_speed, frame_blend, frame_loop, restart);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ private:
|
||||||
// get_physics_override(self)
|
// get_physics_override(self)
|
||||||
static int l_get_physics_override(lua_State *L);
|
static int l_get_physics_override(lua_State *L);
|
||||||
|
|
||||||
// set_animation(self, frame_range, frame_speed, frame_blend, frame_loop, save_playback_pos)
|
// set_animation(self, frame_range, frame_speed, frame_blend, frame_loop, restart)
|
||||||
static int l_set_animation(lua_State *L);
|
static int l_set_animation(lua_State *L);
|
||||||
|
|
||||||
// get_animation(self)
|
// get_animation(self)
|
||||||
|
|
|
@ -151,7 +151,7 @@ public:
|
||||||
{ return ItemGroupList(); }
|
{ return ItemGroupList(); }
|
||||||
virtual void setPhysicsOverride(float physics_override_speed, float physics_override_jump, float physics_override_gravity)
|
virtual void setPhysicsOverride(float physics_override_speed, float physics_override_jump, float physics_override_gravity)
|
||||||
{}
|
{}
|
||||||
virtual void setAnimation(v2f frames, float frame_speed, float frame_blend, bool frame_loop, bool save_playback_pos)
|
virtual void setAnimation(v2f frames, float frame_speed, float frame_blend, bool frame_loop, bool restart)
|
||||||
{}
|
{}
|
||||||
virtual void getAnimation(v2f *frames, float *frame_speed, float *frame_blend, bool *frame_loop)
|
virtual void getAnimation(v2f *frames, float *frame_speed, float *frame_blend, bool *frame_loop)
|
||||||
{}
|
{}
|
||||||
|
|
Loading…
Reference in New Issue