aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2016-09-15 22:40:19 +0100
committerparamat <mat.gregory@virginmedia.com>2016-09-17 09:33:25 +0100
commit3aefa5d3ceaaa9299f42cc10921dec65fa53c5e0 (patch)
treebccc3be37d612d0f7c2e30aa9f3df117b7f1e4ab /builtin
parent297546af3d3b5b3a07a61ade041ad7c26e9a531d (diff)
downloadminetest-3aefa5d3ceaaa9299f42cc10921dec65fa53c5e0.tar.gz
minetest-3aefa5d3ceaaa9299f42cc10921dec65fa53c5e0.tar.bz2
minetest-3aefa5d3ceaaa9299f42cc10921dec65fa53c5e0.zip
Register.lua: Throw error if node 'light_source' > core.LIGHT_MAX
Add 'core.LIGHT_MAX = 14' to builtin/game/constants.lua with the intention to replace misplaced 'default.LIGHT_MAX = 14' in Minetest Game. Add comment in light.h requiring the constant be changed in both places. Add lighting bug warning to note in lua_api.txt. There are hundreds of mod uses of 15 which causes a lighting bug.
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/constants.lua5
-rw-r--r--builtin/game/register.lua3
2 files changed, 8 insertions, 0 deletions
diff --git a/builtin/game/constants.lua b/builtin/game/constants.lua
index 56fca9289..50c515b24 100644
--- a/builtin/game/constants.lua
+++ b/builtin/game/constants.lua
@@ -19,4 +19,9 @@ core.EMERGE_FROM_DISK = 3
core.EMERGE_GENERATED = 4
-- constants.h
+-- Size of mapblocks in nodes
core.MAP_BLOCKSIZE = 16
+
+-- light.h
+-- Maximum value for node 'light_source' parameter
+core.LIGHT_MAX = 14
diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index 05dc5fef8..d3f6b3df8 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -127,6 +127,9 @@ function core.register_item(name, itemdef)
fixed = {-1/8, -1/2, -1/8, 1/8, 1/2, 1/8},
}
end
+ if itemdef.light_source and itemdef.light_source > core.LIGHT_MAX then
+ error("Unable to register node: 'light_source' exceeds maximum: " .. name)
+ end
setmetatable(itemdef, {__index = core.nodedef_default})
core.registered_nodes[itemdef.name] = itemdef
elseif itemdef.type == "craft" then