diff options
author | MirceaKitsune <sonichedgehog_hyperblast00@yahoo.com> | 2012-10-27 01:49:01 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-11-25 18:14:15 +0200 |
commit | e42eeec8f626acbaa54ae31c10ca06c868c7931c (patch) | |
tree | 61ea64416548b5ad858c6d275da90ace607fd163 /src/scriptapi.cpp | |
parent | 118285e6babd511c285780b07c275d527d7da9b1 (diff) | |
download | hax-minetest-server-e42eeec8f626acbaa54ae31c10ca06c868c7931c.tar.gz hax-minetest-server-e42eeec8f626acbaa54ae31c10ca06c868c7931c.zip |
Framework for the attachment system, new object property which allows changing the color and alpha of mesh materials
New object property which allows changing the color and alpha of mesh materials. Due to the current lighting systems it doesn't work yet, but the full implementation is there
Framework for the attachment system, with no actual functionality yet
Send bone and player object to the setAttachment function in content_sao.cpp, but we need a way to translate it there and send it to the client
I will also want position and rotation offsets to be possible to apply to attachments
Network object ID from server to client. This will be used to identify the parent client-side and know what to attach to
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r-- | src/scriptapi.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 3e187d2f6..9c5bbcc5b 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -960,6 +960,23 @@ static void read_object_properties(lua_State *L, int index, } } lua_pop(L, 1); + + lua_getfield(L, -1, "colors"); + if(lua_istable(L, -1)){ + prop->colors.clear(); + int table = lua_gettop(L); + lua_pushnil(L); + while(lua_next(L, table) != 0){ + // key at index -2 and value at index -1 + if(lua_isstring(L, -1)) + prop->colors.push_back(readARGB8(L, -1)); + else + prop->colors.push_back(video::SColor(255, 255, 255, 255)); + // removes value, keeps key for next iteration + lua_pop(L, 1); + } + } + lua_pop(L, 1); lua_getfield(L, -1, "spritediv"); if(lua_istable(L, -1)) @@ -2741,6 +2758,33 @@ private: return 0; } +// Part of the attachment structure, not used yet! + // set_attachment() // <- parameters here + static int l_set_attachment(lua_State *L) + { + ObjectRef *ref = checkobject(L, 1); + ObjectRef *parent_ref = checkobject(L, 2); + ServerActiveObject *co = getobject(ref); + ServerActiveObject *parent = getobject(parent_ref); + if(co == NULL) return 0; + if(parent == NULL) return 0; + std::string bone = ""; + if(!lua_isnil(L, 3)) + bone = lua_tostring(L, 3); + v3f position = v3f(0, 0, 0); + if(!lua_isnil(L, 4)) + position = read_v3f(L, 4); + v3f rotation = v3f(0, 0, 0); + if(!lua_isnil(L, 5)) + rotation = read_v3f(L, 5); + // Do it + +//lua_pushnumber(L, cobj->getId()); // Push id + + co->setAttachment(parent, bone, position, rotation); + return 0; + } + // set_properties(self, properties) static int l_set_properties(lua_State *L) { @@ -3057,6 +3101,7 @@ const luaL_reg ObjectRef::methods[] = { method(ObjectRef, set_armor_groups), method(ObjectRef, set_animations), method(ObjectRef, set_bone_posrot), + method(ObjectRef, set_attachment), method(ObjectRef, set_properties), // LuaEntitySAO-only method(ObjectRef, setvelocity), |