aboutsummaryrefslogtreecommitdiff
path: root/display_api
diff options
context:
space:
mode:
authorNiklp <89982526+Niklp09@users.noreply.github.com>2023-07-24 09:59:26 +0200
committerGitHub <noreply@github.com>2023-07-24 09:59:26 +0200
commit1440f35fa62fd2c01b4844261290c88e42d2430f (patch)
treee42db53056e5d6f1c4fd562a924934081ae787c4 /display_api
parente0e03058362e038d07d4063c4fbd6999ad27109c (diff)
downloaddisplay_modpack_no_craft-1440f35fa62fd2c01b4844261290c88e42d2430f.tar.gz
display_modpack_no_craft-1440f35fa62fd2c01b4844261290c88e42d2430f.zip
Add luacheck, update translations, replace ABMs, bug fixes (#1)
* luacheck, mt 5 translation, german translation, maintenance * fix luacheck warnings * Fix digital clock nodebox and texture * Fix luacheck usage * Add comment why fonts are not split into several lines
Diffstat (limited to 'display_api')
-rw-r--r--display_api/deprecation.lua8
-rw-r--r--display_api/display.lua45
2 files changed, 9 insertions, 44 deletions
diff --git a/display_api/deprecation.lua b/display_api/deprecation.lua
index b041f6f..36e1ecd 100644
--- a/display_api/deprecation.lua
+++ b/display_api/deprecation.lua
@@ -19,17 +19,17 @@
-- Deprecation
-function deprecated_group(deprecated_group, replacement_group)
+local function deprecated_group(old_group, replacement_group)
for name, ndef in pairs(minetest.registered_nodes) do
- if ndef.groups and ndef.groups[deprecated_group] then
+ if ndef.groups and ndef.groups[old_group] then
minetest.log("warning", string.format(
'Node %s belongs to deprecated "%s" group which should be replaced with new "%s" group.',
- name, deprecated_group, replacement_group))
+ name, old_group, replacement_group))
end
end
end
-function deprecated_global_table(deprecated_global_name, replacement_global_name)
+local function deprecated_global_table(deprecated_global_name, replacement_global_name)
assert(type(deprecated_global_name) == 'string', "deprecated_global_name should be a string.")
assert(type(replacement_global_name) == 'string', "replacement_global_name should be a string.")
assert(deprecated_global_name ~= '', "deprecated_global_name should not be empty.")
diff --git a/display_api/display.lua b/display_api/display.lua
index fa7c854..2baef11 100644
--- a/display_api/display.lua
+++ b/display_api/display.lua
@@ -65,9 +65,7 @@ local function compute_values(r)
for _ = 1, r.x do d, w, h = rx(d), rx(w), rx(h) end
for _ = 1, r.y do d, w, h = ry(d), ry(w), ry(h) end
- return {
- rotation=r, depth=d, width=w, height=h,
- restricted=(r.x==0 and r.z==0) }
+ return {rotation=r, depth=d, width=w, height=h}
end
for i, r in pairs(facedir_rotations) do
@@ -78,25 +76,6 @@ for i, r in pairs(wallmounted_rotations) do
wallmounted_values[i] = compute_values(r)
end
--- Detect rotation restriction
-local rotation_restricted = nil
-minetest.register_entity('display_api:dummy_entity', {
- collisionbox = { 0, 0, 0, 0, 0, 0 },
- visual = "upright_sprite",
- textures = {} })
-
-function display_api.is_rotation_restricted()
- if rotation_restricted == nil then
- local objref = minetest.add_entity(
- {x=0, y=0, z=0}, 'display_api:dummy_entity')
- if objref then
- rotation_restricted = objref.set_rotation == nil
- objref:remove()
- end
- end
- return rotation_restricted
-end
-
-- Clip position property to maximum entity position
local function clip_pos_prop(posprop)
@@ -243,16 +222,6 @@ function display_api.on_place(itemstack, placer, pointed_thing, override_param2)
z = pointed_thing.under.z - pointed_thing.above.z,
}
- local rotation_restriction = display_api.is_rotation_restricted()
-
- if rotation_restriction then
- -- If item is not placed on a wall, use the player's view direction instead
- if dir.x == 0 and dir.z == 0 then
- dir = placer:get_look_dir()
- end
- dir.y = 0
- end
-
local param2 = 0
if ndef then
if ndef.paramtype2 == "wallmounted" or
@@ -261,7 +230,7 @@ function display_api.on_place(itemstack, placer, pointed_thing, override_param2)
elseif ndef.paramtype2 == "facedir" or
ndef.paramtype2 == "colorfacedir" then
- param2 = minetest.dir_to_facedir(dir, not rotation_restriction)
+ param2 = minetest.dir_to_facedir(dir, true)
end
end
return minetest.item_place(itemstack, placer, pointed_thing,
@@ -291,13 +260,9 @@ function display_api.on_rotate(pos, node, user, _, new_param2)
return
end
- if ov.restricted or not display_api.is_rotation_restricted() then
- minetest.swap_node(pos, node)
- display_api.update_entities(pos)
- return true
- else
- return false
- end
+ minetest.swap_node(pos, node)
+ display_api.update_entities(pos)
+ return true
end
--- Creates display entity with some fields and the on_activate callback