diff options
author | Rob Blanckaert <rob@withpiper.com> | 2017-09-01 23:12:15 -0700 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-09-14 04:06:05 +0100 |
commit | a9d43a04713dd0342d675f3bbb5cbacd863b4118 (patch) | |
tree | dde4ca88964a67c1a27211eca6f6fcf96fc246d0 /src/script/common | |
parent | 604fe2083d70fea92b6c53c9a9d1c1ffdcb36610 (diff) | |
download | minetest-a9d43a04713dd0342d675f3bbb5cbacd863b4118.tar.gz minetest-a9d43a04713dd0342d675f3bbb5cbacd863b4118.tar.bz2 minetest-a9d43a04713dd0342d675f3bbb5cbacd863b4118.zip |
Object properties: Add 'glow', disables light's effect if negative
The 'glow' value is added to the ambient light value.
Negative 'glow' disables light's effect on object colour, for faking
self-lighting, UI-style entities, or programmatic colouring in mods.
Diffstat (limited to 'src/script/common')
-rw-r--r-- | src/script/common/c_content.cpp | 3 | ||||
-rw-r--r-- | src/script/common/c_converter.cpp | 13 | ||||
-rw-r--r-- | src/script/common/c_converter.h | 2 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index ad92741f8..206ca55d0 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -277,6 +277,7 @@ void read_object_properties(lua_State *L, int index, } lua_pop(L, 1); getboolfield(L, -1, "backface_culling", prop->backface_culling); + getintfield(L, -1, "glow", prop->glow); getstringfield(L, -1, "nametag", prop->nametag); lua_getfield(L, -1, "nametag_color"); @@ -362,6 +363,8 @@ void push_object_properties(lua_State *L, ObjectProperties *prop) lua_setfield(L, -2, "automatic_face_movement_dir"); lua_pushboolean(L, prop->backface_culling); lua_setfield(L, -2, "backface_culling"); + lua_pushnumber(L, prop->glow); + lua_setfield(L, -2, "glow"); lua_pushlstring(L, prop->nametag.c_str(), prop->nametag.size()); lua_setfield(L, -2, "nametag"); push_ARGB8(L, prop->nametag_color); diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp index e5d89dea9..8f88aeb60 100644 --- a/src/script/common/c_converter.cpp +++ b/src/script/common/c_converter.cpp @@ -427,6 +427,19 @@ bool getintfield(lua_State *L, int table, } bool getintfield(lua_State *L, int table, + const char *fieldname, s8 &result) +{ + lua_getfield(L, table, fieldname); + bool got = false; + if (lua_isnumber(L, -1)) { + result = lua_tointeger(L, -1); + got = true; + } + lua_pop(L, 1); + return got; +} + +bool getintfield(lua_State *L, int table, const char *fieldname, u16 &result) { lua_getfield(L, table, fieldname); diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h index f94996c88..18b8f6531 100644 --- a/src/script/common/c_converter.h +++ b/src/script/common/c_converter.h @@ -55,6 +55,8 @@ bool getintfield(lua_State *L, int table, bool getintfield(lua_State *L, int table, const char *fieldname, u8 &result); bool getintfield(lua_State *L, int table, + const char *fieldname, s8 &result); +bool getintfield(lua_State *L, int table, const char *fieldname, u16 &result); bool getintfield(lua_State *L, int table, const char *fieldname, u32 &result); |