1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add particle animation, glow

This is implemented by reusing and extending the
TileAnimation code for the methods used by particles.
This commit is contained in:
sfan5 2017-01-14 16:48:49 +01:00
parent c5967f75f0
commit 7279f0b373
16 changed files with 311 additions and 78 deletions

View file

@ -322,7 +322,7 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype)
}
else if(lua_istable(L, index))
{
// {name="default_lava.png", animation={}}
// name="default_lava.png"
tiledef.name = "";
getstringfield(L, index, "name", tiledef.name);
getstringfield(L, index, "image", tiledef.name); // MaterialSpec compat.
@ -334,28 +334,7 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype)
L, index, "tileable_vertical", default_tiling);
// animation = {}
lua_getfield(L, index, "animation");
if(lua_istable(L, -1)){
tiledef.animation.type = (TileAnimationType)
getenumfield(L, -1, "type", es_TileAnimationType,
TAT_NONE);
if (tiledef.animation.type == TAT_VERTICAL_FRAMES) {
// {type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}
tiledef.animation.vertical_frames.aspect_w =
getintfield_default(L, -1, "aspect_w", 16);
tiledef.animation.vertical_frames.aspect_h =
getintfield_default(L, -1, "aspect_h", 16);
tiledef.animation.vertical_frames.length =
getfloatfield_default(L, -1, "length", 1.0);
} else if (tiledef.animation.type == TAT_SHEET_2D) {
// {type="sheet_2d", frames_w=5, frames_h=3, frame_length=0.5}
getintfield(L, -1, "frames_w",
tiledef.animation.sheet_2d.frames_w);
getintfield(L, -1, "frames_h",
tiledef.animation.sheet_2d.frames_h);
getfloatfield(L, -1, "frame_length",
tiledef.animation.sheet_2d.frame_length);
}
}
tiledef.animation = read_animation_definition(L, -1);
lua_pop(L, 1);
}
@ -925,6 +904,41 @@ void read_inventory_list(lua_State *L, int tableindex,
}
}
/******************************************************************************/
struct TileAnimationParams read_animation_definition(lua_State *L, int index)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
struct TileAnimationParams anim;
anim.type = TAT_NONE;
if (!lua_istable(L, index))
return anim;
anim.type = (TileAnimationType)
getenumfield(L, index, "type", es_TileAnimationType,
TAT_NONE);
if (anim.type == TAT_VERTICAL_FRAMES) {
// {type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}
anim.vertical_frames.aspect_w =
getintfield_default(L, index, "aspect_w", 16);
anim.vertical_frames.aspect_h =
getintfield_default(L, index, "aspect_h", 16);
anim.vertical_frames.length =
getfloatfield_default(L, index, "length", 1.0);
} else if (anim.type == TAT_SHEET_2D) {
// {type="sheet_2d", frames_w=5, frames_h=3, frame_length=0.5}
getintfield(L, index, "frames_w",
anim.sheet_2d.frames_w);
getintfield(L, index, "frames_h",
anim.sheet_2d.frames_h);
getfloatfield(L, index, "frame_length",
anim.sheet_2d.frame_length);
}
return anim;
}
/******************************************************************************/
ToolCapabilities read_tool_capabilities(
lua_State *L, int table)

View file

@ -79,6 +79,7 @@ void push_hit_params (lua_State *L,
ItemStack read_item (lua_State *L, int index, Server *srv);
struct TileAnimationParams read_animation_definition(lua_State *L, int index);
ToolCapabilities read_tool_capabilities (lua_State *L, int table);
void push_tool_capabilities (lua_State *L,