diff --git a/ontime_clocks/common.lua b/ontime_clocks/common.lua index 2c7639f..9bd7bb2 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 @@ -58,4 +62,3 @@ function ontime_clocks.get_needles_properties(color, size, hour, minute) visual_size = {x=size/64, y=size/64} } end - diff --git a/ontime_clocks/crafts.lua b/ontime_clocks/crafts.lua index fa218a2..f2bef22 100644 --- a/ontime_clocks/crafts.lua +++ b/ontime_clocks/crafts.lua @@ -56,6 +56,24 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = 'ontime_clocks:3x3_clock_black', + recipe = { + {mat.steel_ingot, mat.dye_black, mat.steel_ingot}, + {'', 'ontime_clocks:frameless_black', ''}, + {'', '', ''}, + } +}) + +minetest.register_craft({ + output = 'ontime_clocks:5x5_clock_black', + recipe = { + {mat.steel_ingot, mat.dye_black, mat.steel_ingot}, + {'', 'ontime_clocks:3x3_clock_black', ''}, + {'', '', ''}, + } +}) + minetest.register_craft({ output = 'ontime_clocks:frameless_gold', recipe = { @@ -65,6 +83,24 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = 'ontime_clocks:3x3_clock_gold', + recipe = { + {mat.gold_ingot, '', mat.gold_ingot}, + {'', 'ontime_clocks:frameless_gold', ''}, + {'', '', ''}, + } +}) + +minetest.register_craft({ + output = 'ontime_clocks:5x5_clock_gold', + recipe = { + {mat.gold_ingot, '', mat.gold_ingot}, + {'', 'ontime_clocks:3x3_clock_gold', ''}, + {'', '', ''}, + } +}) + minetest.register_craft({ output = 'ontime_clocks:frameless_white', recipe = { @@ -74,4 +110,21 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = 'ontime_clocks:3x3_clock_white', + recipe = { + {mat.steel_ingot, mat.dye_white, mat.steel_ingot}, + {'', 'ontime_clocks:frameless_white', ''}, + {'', '', ''}, + } +}) + +minetest.register_craft({ + output = 'ontime_clocks:5x5_clock_white', + recipe = { + {mat.steel_ingot, mat.dye_white, mat.steel_ingot}, + {'', 'ontime_clocks:3x3_clock_white', ''}, + {'', '', ''}, + } +}) diff --git a/ontime_clocks/design/ontime_clocks_large_clock_inventory.svg b/ontime_clocks/design/ontime_clocks_large_clock_inventory.svg new file mode 100644 index 0000000..7a48932 --- /dev/null +++ b/ontime_clocks/design/ontime_clocks_large_clock_inventory.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ontime_clocks/design/ontime_clocks_large_clock_parts.svg b/ontime_clocks/design/ontime_clocks_large_clock_parts.svg new file mode 100644 index 0000000..23833a9 --- /dev/null +++ b/ontime_clocks/design/ontime_clocks_large_clock_parts.svg @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ontime_clocks/locale/ontime_clocks.de.tr b/ontime_clocks/locale/ontime_clocks.de.tr index 5bdb660..2fc1555 100644 --- a/ontime_clocks/locale/ontime_clocks.de.tr +++ b/ontime_clocks/locale/ontime_clocks.de.tr @@ -2,6 +2,15 @@ Green digital clock=Grüne Digitaluhr Red digital clock=Rote Digitaluhr White clock=Weiße Uhr +@1 frameless @2 clock= +gold= +black= +white= +Frameless @1 clock= + + +##### not used anymore ##### + Frameless clock=Rahmenlose Uhr Frameless gold clock=Rahmenlose goldene Uhr Frameless white clock=Rahmenlose weiße Uhr diff --git a/ontime_clocks/locale/ontime_clocks.fr.tr b/ontime_clocks/locale/ontime_clocks.fr.tr index fdc8ccf..9011d30 100644 --- a/ontime_clocks/locale/ontime_clocks.fr.tr +++ b/ontime_clocks/locale/ontime_clocks.fr.tr @@ -2,6 +2,8 @@ Green digital clock=Horloge numérique verte Red digital clock=Horloge numérique rouge White clock=Horloge blanche -Frameless clock=Horloge sans cadre -Frameless gold clock=Horloge dorée sans cadre -Frameless white clock=Horloge blanche sans cadre +@1 frameless @2 clock=Horloge @2 sans cadre @1 +gold=dorée +black=noire +white=blanche +Frameless @1 clock=Horloge @1 sans cadre diff --git a/ontime_clocks/locale/ontime_clocks.ms.tr b/ontime_clocks/locale/ontime_clocks.ms.tr index 0478935..6e4f6d8 100644 --- a/ontime_clocks/locale/ontime_clocks.ms.tr +++ b/ontime_clocks/locale/ontime_clocks.ms.tr @@ -2,6 +2,15 @@ Green digital clock=Jam digital hijau Red digital clock=Jam digital merah White clock=Jam putih +@1 frameless @2 clock= +gold= +black= +white= +Frameless @1 clock= + + +##### not used anymore ##### + Frameless clock=Jam tanpa bingkai Frameless gold clock=Jam emas tanpa bingkai Frameless white clock=Jam putih tanpa bingkai diff --git a/ontime_clocks/locale/template.txt b/ontime_clocks/locale/template.txt index 6db07cb..84941b0 100644 --- a/ontime_clocks/locale/template.txt +++ b/ontime_clocks/locale/template.txt @@ -2,6 +2,8 @@ Green digital clock= Red digital clock= White clock= -Frameless clock= -Frameless gold clock= -Frameless white clock= +@1 frameless @2 clock= +gold= +black= +white= +Frameless @1 clock= diff --git a/ontime_clocks/nodes.lua b/ontime_clocks/nodes.lua index afa28fe..768a574 100644 --- a/ontime_clocks/nodes.lua +++ b/ontime_clocks/nodes.lua @@ -31,8 +31,31 @@ local function clock_on_timer(pos) return true end +minetest.register_lbm({ + name = "ontime_clocks:nodetimer_init", + nodenames = {"group:ontime_clocks_tick"}, + run_at_every_load = false, + action = function(pos) + local timer = minetest.get_node_timer(pos) + timer:start(5) + end +}) + +local function register_clock(name, def) + def.on_place = display_api.on_place + def.on_construct = clock_on_construct + def.on_destruct = display_api.on_destruct + def.on_blast = display_api.on_blast + def.on_rotate = display_api.on_rotate + def.on_timer = clock_on_timer + def.groups.ontime_clocks_tick = 1 + def.groups.display_api = 1 + + minetest.register_node(name, def) +end + -- Green digital clock -minetest.register_node("ontime_clocks:green_digital", { +register_clock("ontime_clocks:green_digital", { description = S("Green digital clock"), inventory_image = "ontime_clocks_green_digital_inventory.png", wield_image = "ontime_clocks_green_digital_inventory.png", @@ -46,7 +69,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 = {oddly_breakable_by_hand=1, not_blocking_trains=1, handy = 1}, _mcl_hardness = 0.8, _mcl_blast_resistance = 1, is_ground_content = false, @@ -59,17 +82,11 @@ minetest.register_node("ontime_clocks:green_digital", { "#040", "#0F0", ontime_clocks.get_h24(), ontime_clocks.get_m12())) 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, }) -- Red digital clock -minetest.register_node("ontime_clocks:red_digital", { +register_clock("ontime_clocks:red_digital", { description = S("Red digital clock"), inventory_image = "ontime_clocks_red_digital_inventory.png", wield_image = "ontime_clocks_red_digital_inventory.png", @@ -83,7 +100,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 = {oddly_breakable_by_hand=1, not_blocking_trains=1, handy = 1}, _mcl_hardness = 0.8, _mcl_blast_resistance = 1, is_ground_content = false, @@ -96,16 +113,10 @@ minetest.register_node("ontime_clocks:red_digital", { "#400", "#F00", ontime_clocks.get_h24(), ontime_clocks.get_m12())) 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, }) -minetest.register_node("ontime_clocks:white", { +register_clock("ontime_clocks:white", { description = S("White clock"), inventory_image = "ontime_clocks_white_inventory.png", wield_image = "ontime_clocks_white_inventory.png", @@ -119,7 +130,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 = {oddly_breakable_by_hand=1, not_blocking_trains=1, handy = 1}, _mcl_hardness = 0.8, _mcl_blast_resistance = 1, is_ground_content = false, @@ -132,133 +143,105 @@ minetest.register_node("ontime_clocks:white", { "#000", 36, ontime_clocks.get_h12(), ontime_clocks.get_m12())) 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, }) +local function register_large_clock(name, label, color, size) + local sstr = size .. "x" .. size -- Size string + register_clock("ontime_clocks:" .. sstr .. "_clock_" .. name, { + description = S("@1 frameless @2 clock", sstr, label), + inventory_image = "ontime_clocks_large_clock_inventory.png^[colorize:" .. + color .. "^ontime_clocks_" .. sstr .. "_clock_inventory.png", + wield_image = "ontime_clocks_large_clock_inventory.png^[colorize:" .. color, + paramtype = "light", + paramtype2 = "wallmounted", + drawtype = "nodebox", + use_texture_alpha = "clip", + node_box = { + type = "wallmounted", + wall_side = { -0.5, -7/16, -7/16, -15/32, 7/16, 7/16 }, + wall_bottom = { -7/16, -0.5, -7/16, 7/16, -15/32, 7/16 }, + wall_top = { -7/16, 0.5, -7/16, 7/16, 15/32, 7/16 } + }, + tiles = {"ontime_clocks_" .. sstr .. "_center.png^[colorize:" .. color}, + groups = {oddly_breakable_by_hand = 1, not_blocking_trains = 1, handy = 1}, + _mcl_hardness = 0.8, + _mcl_blast_resistance = 1, + is_ground_content = false, + display_entities = { + ["ontime_clocks:hours_needle"] = { + depth = 14/32, + on_display_update = function(pos, objref) + objref:set_properties({ + textures={"ontime_clocks_" .. sstr .. "_needle_hours.png^[colorize:" .. color}, + visual_size = {x=1, y=size}, + }) + objref:get_luaentity()["rotation"] = { + z = math.floor(minetest.get_timeofday() * 24) / 6 * math.pi + } + end + }, + ["ontime_clocks:minutes_needle"] = { + depth = 13/32, + on_display_update = function(pos, objref) + objref:set_properties({ + textures={"ontime_clocks_" .. sstr .. "_needle_minutes.png^[colorize:" .. color}, + visual_size = {x=1, y=size}, + }) + objref:get_luaentity()["rotation"] = { + z = math.floor(minetest.get_timeofday() * 288) / 6 * math.pi + } + end + }, + }, + }) +end -minetest.register_node("ontime_clocks:frameless_black", { - description = S("Frameless clock"), - inventory_image = "ontime_clocks_frameless_inventory.png", - wield_image = "ontime_clocks_frameless_inventory.png", - 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.png"}, - groups = {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:display"] = { - depth = 7/16, - on_display_update = function(pos, objref) - objref:set_properties( - ontime_clocks.get_needles_properties( - "#000", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12())) - 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, -}) +local models = { + { name = "gold", label = S("gold"), color = "#FF0" }, + { name = "black", label = S("black"), color = "#000" }, + { name = "white", label = S("white"), color = "#FFF" }, +} +for _, model in ipairs(models) do + -- Frameless clock + register_clock("ontime_clocks:frameless_" .. model.name, { + description = S("Frameless @1 clock", model.label), + inventory_image = "ontime_clocks_frameless_inventory.png^[colorize:" .. model.color, + wield_image = "ontime_clocks_frameless_inventory.png^[colorize:" .. model.color, + 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.png^[colorize:" .. model.color}, + groups = { oddly_breakable_by_hand=1, not_blocking_trains=1, handy = 1}, + _mcl_hardness = 0.8, + _mcl_blast_resistance = 1, + is_ground_content = false, + display_entities = { + ["ontime_clocks:display"] = { + depth = 7/16, + on_display_update = function(pos, objref) + objref:set_properties( + ontime_clocks.get_needles_properties( + model.color, 48, + ontime_clocks.get_h12(), + ontime_clocks.get_m12() + ) + ) + end }, + }, + }) -minetest.register_node("ontime_clocks:frameless_gold", { - description = S("Frameless gold clock"), - inventory_image = "ontime_clocks_frameless_inventory.png^[colorize:#FF0", - wield_image = "ontime_clocks_frameless_inventory.png^[colorize:#FF0", - 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.png^[colorize:#FF0"}, - groups = {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:display"] = { - depth = 7/16, - on_display_update = function(pos, objref) - objref:set_properties( - ontime_clocks.get_needles_properties( - "#FF0", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12())) - 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, -}) + -- 3x3 large clock + register_large_clock(model.name, model.label, model.color, 3) + -- 5x5 large clock + register_large_clock(model.name, model.label, model.color, 5) +end -minetest.register_node("ontime_clocks:frameless_white", { - description = S("Frameless white 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.png^[colorize:#FFF"}, - groups = {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:display"] = { - depth = 7/16, - on_display_update = function(pos, objref) - objref:set_properties( - ontime_clocks.get_needles_properties( - "#FFF", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12())) - 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, -}) - - -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"}, - run_at_every_load = false, - action = function(pos) - local timer = minetest.get_node_timer(pos) - timer:start(5) - end -}) diff --git a/ontime_clocks/textures/ontime_clocks_3x3_center.png b/ontime_clocks/textures/ontime_clocks_3x3_center.png new file mode 100644 index 0000000..5d01630 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_3x3_center.png differ diff --git a/ontime_clocks/textures/ontime_clocks_3x3_clock_inventory.png b/ontime_clocks/textures/ontime_clocks_3x3_clock_inventory.png new file mode 100644 index 0000000..85537ed Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_3x3_clock_inventory.png differ diff --git a/ontime_clocks/textures/ontime_clocks_3x3_needle_hours.png b/ontime_clocks/textures/ontime_clocks_3x3_needle_hours.png new file mode 100644 index 0000000..d3e6561 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_3x3_needle_hours.png differ diff --git a/ontime_clocks/textures/ontime_clocks_3x3_needle_minutes.png b/ontime_clocks/textures/ontime_clocks_3x3_needle_minutes.png new file mode 100644 index 0000000..d634428 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_3x3_needle_minutes.png differ diff --git a/ontime_clocks/textures/ontime_clocks_5x5_center.png b/ontime_clocks/textures/ontime_clocks_5x5_center.png new file mode 100644 index 0000000..92eab52 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_5x5_center.png differ diff --git a/ontime_clocks/textures/ontime_clocks_5x5_clock_inventory.png b/ontime_clocks/textures/ontime_clocks_5x5_clock_inventory.png new file mode 100644 index 0000000..14572f2 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_5x5_clock_inventory.png differ diff --git a/ontime_clocks/textures/ontime_clocks_5x5_needle_hours.png b/ontime_clocks/textures/ontime_clocks_5x5_needle_hours.png new file mode 100644 index 0000000..4e081ce Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_5x5_needle_hours.png differ diff --git a/ontime_clocks/textures/ontime_clocks_5x5_needle_minutes.png b/ontime_clocks/textures/ontime_clocks_5x5_needle_minutes.png new file mode 100644 index 0000000..f086d80 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_5x5_needle_minutes.png differ diff --git a/ontime_clocks/textures/ontime_clocks_large_clock_inventory.png b/ontime_clocks/textures/ontime_clocks_large_clock_inventory.png new file mode 100644 index 0000000..ee9b773 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_large_clock_inventory.png differ