1
0
mirror of https://github.com/pyrollo/display_modpack.git synced 2025-10-14 16:25:20 +02:00
This commit is contained in:
Pierre-Yves Rollo
2025-09-29 09:17:36 +02:00
parent 0ec62a1732
commit d96ca765b1
9 changed files with 330 additions and 31 deletions

View File

@@ -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,14 +278,18 @@ 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
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
pointable = false,
},
on_activate = display_api.on_activate,
get_staticdata = function(self)
@@ -294,7 +300,6 @@ function display_api.register_display_entity(entity_name)
end,
})
end
end
minetest.register_lbm({
label = "Update display_api entities",

View File

@@ -18,9 +18,13 @@
along with ontime_clocks. If not, see <http://www.gnu.org/licenses/>.
--]]
-- 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

View File

@@ -0,0 +1,214 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="needles.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="true"
inkscape:zoom="7.6898429"
inkscape:cx="144.73638"
inkscape:cy="77.179731"
inkscape:window-width="1720"
inkscape:window-height="1282"
inkscape:window-x="26"
inkscape:window-y="23"
inkscape:window-maximized="0"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid132"
empspacing="8"
empcolor="#9f00e5"
empopacity="0.30196078" />
</sodipodi:namedview>
<defs
id="defs2" />
<g
inkscape:label="Guides"
inkscape:groupmode="layer"
id="layer1"
style="display:none">
<g
id="g1880"
inkscape:label="minutes 3x3"
transform="matrix(2.0000002,0,0,2.333333,-33.866673,-23.636102)"
style="stroke-width:0.46291"
inkscape:export-filename="../textures/ontime_clocks_needle_minutes_3x3.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<rect
style="fill:#ff0000;fill-opacity:0.2;fill-rule:evenodd;stroke:none;stroke-width:0.231455;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stop-color:#000000"
id="rect236"
width="2.1166666"
height="6.3500009"
x="31.75"
y="16.933332"
inkscape:label="Size" />
<path
style="fill:#ff0000;stroke:#ff0000;stroke-width:0.0231455;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:0.5"
d="m 31.75,20.108333 h 2.116666"
id="path1869" />
<path
style="fill:#ff0000;stroke:#ff0000;stroke-width:0.0231455;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:0.5"
d="m 32.808333,16.933333 v 6.35"
id="path1871" />
</g>
<g
id="g1885"
inkscape:label="minutes 5x5"
transform="matrix(1.9999998,0,0,1.9999995,-35.983327,-16.933324)"
style="stroke-width:0.5"
inkscape:export-filename="../textures/ontime_clocks_needle_minutes_5x5.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<rect
style="fill:#ff0000;fill-opacity:0.2;fill-rule:evenodd;stroke:none;stroke-width:0.250001;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stop-color:#000000"
id="rect236-3"
width="2.1166663"
height="10.583334"
x="35.983334"
y="14.816667"
inkscape:label="Size" />
<path
style="fill:#ff0000;stroke:#ff0000;stroke-width:0.0250001;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:0.5"
d="M 37.041666,25.4 V 14.816666"
id="path1873" />
<path
style="fill:#ff0000;stroke:#ff0000;stroke-width:0.0250001;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:0.5"
d="M 35.983333,20.108333 H 38.1"
id="path1875" />
</g>
<g
id="g1880-6"
inkscape:label="hours 3x3"
transform="matrix(2.0000002,0,0,2.333333,-21.166673,-23.636104)"
style="display:inline;stroke-width:0.46291"
inkscape:export-filename="../textures/ontime_clocks_needle_hours_3x3.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<rect
style="fill:#ff0000;fill-opacity:0.2;fill-rule:evenodd;stroke:none;stroke-width:0.231455;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stop-color:#000000"
id="rect236-2"
width="2.1166666"
height="6.3500009"
x="31.75"
y="16.933332"
inkscape:label="Size" />
<path
style="fill:#ff0000;stroke:#ff0000;stroke-width:0.0231455;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:0.5"
d="m 31.75,20.108333 h 2.116666"
id="path1869-6" />
<path
style="fill:#ff0000;stroke:#ff0000;stroke-width:0.0231455;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:0.5"
d="m 32.808333,16.933333 v 6.35"
id="path1871-1" />
</g>
<g
id="g1885-8"
inkscape:label="hours 5x5"
transform="matrix(1.9999998,0,0,1.9999995,-23.283327,-16.933326)"
style="display:inline;stroke-width:0.5"
inkscape:export-filename="../textures/ontime_clocks_needle_hours_5x5.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<rect
style="fill:#ff0000;fill-opacity:0.2;fill-rule:evenodd;stroke:none;stroke-width:0.250001;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stop-color:#000000"
id="rect236-3-7"
width="2.1166663"
height="10.583334"
x="35.983334"
y="14.816667"
inkscape:label="Size" />
<path
style="fill:#ff0000;stroke:#ff0000;stroke-width:0.0250001;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:0.5"
d="M 37.041666,25.4 V 14.816666"
id="path1873-9" />
<path
style="fill:#ff0000;stroke:#ff0000;stroke-width:0.0250001;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:0.5"
d="M 35.983333,20.108333 H 38.1"
id="path1875-2" />
</g>
</g>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Minutes"
style="display:inline">
<g
id="g4762-7"
transform="matrix(0.4999995,0,0,1.2058823,19.050019,-5.1671564)"
style="stroke-width:1.28784">
<rect
style="fill:#333333;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.0643919;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:0.5;stop-color:#000000"
id="rect1943-0"
width="1.0583333"
height="8.9958334"
x="37.570831"
y="14.816667"
ry="0" />
</g>
<g
id="g4762-3-3"
transform="matrix(0.50000006,0,0,0.85294118,12.699999,3.2372549)"
style="stroke-width:1.53128">
<rect
style="fill:#333333;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.076564;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:0.5;stop-color:#000000"
id="rect1943-5-6"
width="1.0583333"
height="8.9958334"
x="37.570831"
y="14.816667"
ry="0" />
</g>
</g>
<g
inkscape:groupmode="layer"
id="layer3"
inkscape:label="Hours"
style="display:inline">
<g
id="g4762"
transform="translate(12.700002)">
<rect
style="fill:#333333;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.0499999;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:0.5;stop-color:#000000"
id="rect1943"
width="1.0583333"
height="8.9958334"
x="37.570831"
y="14.816667"
ry="0" />
</g>
<g
id="g4762-3"
transform="matrix(1,0,0,0.76470588,6.350002,5.6029412)"
style="stroke-width:1.14354">
<rect
style="fill:#333333;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.0571771;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:0.5;stop-color:#000000"
id="rect1943-5"
width="1.0583333"
height="8.9958334"
x="37.570831"
y="14.816667"
ry="0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@@ -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
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B