diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-03-23 20:23:03 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-03-24 04:24:26 +0200 |
commit | 6c14025b2d416105915440e114de927c26e925ac (patch) | |
tree | 64396513416935f2c0eaf50115a61856bbc0f7f2 /src/scriptapi.cpp | |
parent | e53794868eaa33199a1f1011b2d5f517b6f68057 (diff) | |
download | minetest-6c14025b2d416105915440e114de927c26e925ac.tar.gz minetest-6c14025b2d416105915440e114de927c26e925ac.tar.bz2 minetest-6c14025b2d416105915440e114de927c26e925ac.zip |
Add event manager and use it to trigger sounds
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r-- | src/scriptapi.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 27ab2950b..79da15c49 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -808,6 +808,25 @@ static void push_pointed_thing(lua_State *L, const PointedThing& pointed) } /* + SimpleSoundSpec +*/ + +static SimpleSoundSpec read_soundspec(lua_State *L, int index) +{ + if(index < 0) + index = lua_gettop(L) + 1 + index; + SimpleSoundSpec spec; + if(lua_isnil(L, index)){ + } else if(lua_istable(L, index)){ + getstringfield(L, index, "name", spec.name); + getfloatfield(L, index, "gain", spec.gain); + } else if(lua_isstring(L, index)){ + spec.name = lua_tostring(L, index); + } + return spec; +} + +/* ItemDefinition */ @@ -1038,6 +1057,15 @@ static ContentFeatures read_content_features(lua_State *L, int index) getboolfield(L, index, "legacy_facedir_simple", f.legacy_facedir_simple); // Set to true if wall_mounted used to be set to true getboolfield(L, index, "legacy_wallmounted", f.legacy_wallmounted); + + // Sound table + lua_getfield(L, index, "sounds"); + if(lua_istable(L, -1)){ + lua_getfield(L, -1, "footstep"); + f.sound_footstep = read_soundspec(L, -1); + lua_pop(L, 1); + } + lua_pop(L, 1); return f; } |