diff --git a/display_api/display.lua b/display_api/display.lua
index c329dd7..a676d6d 100644
--- a/display_api/display.lua
+++ b/display_api/display.lua
@@ -147,7 +147,9 @@ function display_api.update_entities(pos)
end
for _, objref in pairs(get_display_objrefs(pos, true)) do
- local edef = ndef.display_entities[objref:get_luaentity().name]
+ local entity = objref:get_luaentity()
+ local edef = ndef.display_entities[entity.name]
+ local oprop = objref:get_properties()
local depth = clip_pos_prop(edef.depth)
local right = clip_pos_prop(edef.right)
local top = clip_pos_prop(edef.top)
@@ -160,9 +162,9 @@ function display_api.update_entities(pos)
if objref.set_rotation then
objref:set_rotation({
- x = ov.rotation.x*math.pi/2,
- y = ov.rotation.y*math.pi/2 + (edef.yaw or 0),
- z = ov.rotation.z*math.pi/2,
+ x = ov.rotation.x * math.pi / 2 + (entity.rotation and entity.rotation.x or 0),
+ y = ov.rotation.y * math.pi / 2 + (entity.rotation and entity.rotation.y or 0) + (edef.yaw or 0),
+ z = ov.rotation.z * math.pi / 2 + (entity.rotation and entity.rotation.z or 0),
})
else
if ov.rotation.x ~=0 or ov.rotation.y ~= 0 then
@@ -276,24 +278,27 @@ end
--- Creates display entity with some fields and the on_activate callback
function display_api.register_display_entity(entity_name)
- if not minetest.registered_entities[entity_name] then
- minetest.register_entity(':'..entity_name, {
- initial_properties = {
- collisionbox = {0, 0, 0, 0, 0, 0},
- visual = "upright_sprite",
- textures = {},
- collide_with_objects = false,
- pointable = false
- },
- on_activate = display_api.on_activate,
- get_staticdata = function(self)
- return minetest.serialize({ nodepos = self.nodepos })
- end,
- on_blast = function(self, damage)
- return false, false, {}
- end,
- })
+
+ if minetest.registered_entities[entity_name] then
+ return
end
+
+ minetest.register_entity(':'..entity_name, {
+ initial_properties = {
+ collisionbox = {0, 0, 0, 0, 0, 0},
+ visual = "upright_sprite",
+ textures = {},
+ collide_with_objects = false,
+ pointable = false,
+ },
+ on_activate = display_api.on_activate,
+ get_staticdata = function(self)
+ return minetest.serialize({ nodepos = self.nodepos })
+ end,
+ on_blast = function(self, damage)
+ return false, false, {}
+ end,
+ })
end
minetest.register_lbm({
diff --git a/ontime_clocks/common.lua b/ontime_clocks/common.lua
index 2c7639f..23fa248 100644
--- a/ontime_clocks/common.lua
+++ b/ontime_clocks/common.lua
@@ -18,9 +18,13 @@
along with ontime_clocks. If not, see .
--]]
--- Entity for time display
+-- Entity for time display of most of clocks
display_api.register_display_entity("ontime_clocks:display")
+-- Entities for two needles of large clocks
+display_api.register_display_entity("ontime_clocks:hours_needle")
+display_api.register_display_entity("ontime_clocks:minutes_needle")
+
function ontime_clocks.get_h24()
return math.floor(minetest.get_timeofday()*24)%24
end
@@ -59,3 +63,11 @@ function ontime_clocks.get_needles_properties(color, size, hour, minute)
}
end
+function ontime_clocks.get_roll_h12()
+ print(minetest.get_timeofday())
+ return minetest.get_timeofday() * math.pi / 12
+end
+
+function ontime_clocks.get_roll_m()
+ return 0
+end
diff --git a/ontime_clocks/design/needles.svg b/ontime_clocks/design/needles.svg
new file mode 100644
index 0000000..53577cc
--- /dev/null
+++ b/ontime_clocks/design/needles.svg
@@ -0,0 +1,214 @@
+
+
+
+
diff --git a/ontime_clocks/nodes.lua b/ontime_clocks/nodes.lua
index afa28fe..2ce6d45 100644
--- a/ontime_clocks/nodes.lua
+++ b/ontime_clocks/nodes.lua
@@ -46,7 +46,7 @@ minetest.register_node("ontime_clocks:green_digital", {
wall_top = {-7/16, 0.5, -7/32, 7/16, 13/32, 3/16}
},
tiles = {"ontime_clocks_digital.png"},
- groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
+ groups = {ontime_clocks_tick=1, oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
is_ground_content = false,
@@ -83,7 +83,7 @@ minetest.register_node("ontime_clocks:red_digital", {
wall_top = {-7/16, 0.5, -7/32, 7/16, 13/32, 3/16}
},
tiles = {"ontime_clocks_digital.png"},
- groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
+ groups = {ontime_clocks_tick=1, oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
is_ground_content = false,
@@ -119,7 +119,7 @@ minetest.register_node("ontime_clocks:white", {
wall_top = { -7/16, 0.5, -7/16, 7/16, 7/16, 7/16},
},
tiles = {"ontime_clocks_white.png"},
- groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
+ groups = {ontime_clocks_tick=1, oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
is_ground_content = false,
@@ -156,7 +156,7 @@ minetest.register_node("ontime_clocks:frameless_black", {
wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
},
tiles = {"ontime_clocks_frameless.png"},
- groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
+ groups = {ontime_clocks_tick=1, oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
is_ground_content = false,
@@ -193,7 +193,7 @@ minetest.register_node("ontime_clocks:frameless_gold", {
wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
},
tiles = {"ontime_clocks_frameless.png^[colorize:#FF0"},
- groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
+ groups = {ontime_clocks_tick=1, oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
is_ground_content = false,
@@ -230,7 +230,7 @@ minetest.register_node("ontime_clocks:frameless_white", {
wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
},
tiles = {"ontime_clocks_frameless.png^[colorize:#FFF"},
- groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
+ groups = {ontime_clocks_tick=1, oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1, handy = 1},
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
is_ground_content = false,
@@ -252,13 +252,81 @@ minetest.register_node("ontime_clocks:frameless_white", {
})
+minetest.register_node("ontime_clocks:large_clock_black", {
+ description = S("Frameless large black clock"),
+ inventory_image = "ontime_clocks_frameless_inventory.png^[colorize:#FFF",
+ wield_image = "ontime_clocks_frameless_inventory.png^[colorize:#FFF",
+ paramtype = "light",
+ paramtype2 = "wallmounted",
+ drawtype = "nodebox",
+ use_texture_alpha = "clip",
+ node_box = {
+ type = "wallmounted",
+ wall_side = { -0.5, -7/16, -7/16, -0.45, 7/16, 7/16 },
+ wall_bottom = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
+ wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
+ },
+ tiles = {"ontime_clocks_frameless_inventory.png"},
+ groups = {ontime_clocks_tick = 1, oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_api = 1, handy = 1},
+ _mcl_hardness = 0.8,
+ _mcl_blast_resistance = 1,
+ is_ground_content = false,
+ display_entities = {
+ ["ontime_clocks:hours_needle"] = {
+ depth = 15/32,
+ on_display_update = function(pos, objref)
+ objref:set_properties({
+ textures={"ontime_clocks_needle_hours_5x5.png"},
+ visual_size = {x=1, y=5},
+ })
+ print( minetest.get_timeofday() )
+ objref:get_luaentity()["rotation"] = { z = math.floor(minetest.get_timeofday() * 24) / 6 * math.pi }
+ end
+ },
+ ["ontime_clocks:minutes_needle"] = {
+ depth = 14/32,
+ on_display_update = function(pos, objref)
+ objref:set_properties({
+ textures={"ontime_clocks_needle_minutes_5x5.png"},
+ visual_size = {x=1, y=5},
+ })
+ objref:get_luaentity()["rotation"] = { z = math.floor(minetest.get_timeofday() * 288) / 6 * math.pi }
+ end
+ },
+ },
+ on_place = display_api.on_place,
+ on_construct = clock_on_construct,
+ on_destruct = display_api.on_destruct,
+ on_blast = display_api.on_blast,
+ on_rotate = display_api.on_rotate,
+ on_timer = clock_on_timer,
+})
+
+function flatten(from, to)
+ local mt = getmetatable(from)
+ if mt ~= nil then
+ flatten(mt, to)
+ end
+ for k, v in pairs(from) do
+ to[k] = v
+ end
+end
+
+function dump(title, table)
+ print("=== " .. title .. " ===", table)
+ local t = {}
+ flatten(table, t)
+ for k,v in pairs(t) do
+ print(k, "=>", v)
+ end
+end
+
minetest.register_lbm({
name = "ontime_clocks:nodetimer_init",
- nodenames = {"ontime_clocks:green_digital", "ontime_clocks:red_digital", "ontime_clocks:white",
- "ontime_clocks:frameless_black", "ontime_clocks:frameless_gold", "ontime_clocks:frameless_white"},
+ nodenames = {"group:ontime_clocks_tick"},
run_at_every_load = false,
action = function(pos)
local timer = minetest.get_node_timer(pos)
- timer:start(5)
+ timer:start(1)
end
})
diff --git a/ontime_clocks/textures/ontime_clocks_black_pixel.png b/ontime_clocks/textures/ontime_clocks_black_pixel.png
new file mode 100644
index 0000000..4f85ea2
Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_black_pixel.png differ
diff --git a/ontime_clocks/textures/ontime_clocks_needle_hours_3x3.png b/ontime_clocks/textures/ontime_clocks_needle_hours_3x3.png
new file mode 100644
index 0000000..31f16bb
Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_needle_hours_3x3.png differ
diff --git a/ontime_clocks/textures/ontime_clocks_needle_hours_5x5.png b/ontime_clocks/textures/ontime_clocks_needle_hours_5x5.png
new file mode 100644
index 0000000..52efd68
Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_needle_hours_5x5.png differ
diff --git a/ontime_clocks/textures/ontime_clocks_needle_minutes_3x3.png b/ontime_clocks/textures/ontime_clocks_needle_minutes_3x3.png
new file mode 100644
index 0000000..eb360bb
Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_needle_minutes_3x3.png differ
diff --git a/ontime_clocks/textures/ontime_clocks_needle_minutes_5x5.png b/ontime_clocks/textures/ontime_clocks_needle_minutes_5x5.png
new file mode 100644
index 0000000..d716e41
Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_needle_minutes_5x5.png differ