From d44bf53ea20136221d605e139f2b58328b68ce9c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Rollo Date: Wed, 11 Nov 2015 14:26:39 +0100 Subject: First commit --- ontime_clocks/LICENSE.txt | 13 ++ ontime_clocks/README.md | 47 +++++ ontime_clocks/common.lua | 41 ++++ ontime_clocks/crafts.lua | 56 ++++++ ontime_clocks/depends.txt | 3 + ontime_clocks/init.lua | 14 ++ ontime_clocks/nodes.lua | 224 +++++++++++++++++++++ ontime_clocks/textures/ontime_clocks_digital.png | Bin 0 -> 208 bytes .../textures/ontime_clocks_digital_background.png | Bin 0 -> 197 bytes .../textures/ontime_clocks_digital_digit.png | Bin 0 -> 223 bytes ontime_clocks/textures/ontime_clocks_frameless.png | Bin 0 -> 241 bytes .../textures/ontime_clocks_frameless_inventory.png | Bin 0 -> 426 bytes .../ontime_clocks_green_digital_inventory.png | Bin 0 -> 300 bytes .../textures/ontime_clocks_needle_h36.png | Bin 0 -> 1533 bytes .../textures/ontime_clocks_needle_h48.png | Bin 0 -> 2517 bytes .../textures/ontime_clocks_needle_m36.png | Bin 0 -> 1902 bytes .../textures/ontime_clocks_needle_m48.png | Bin 0 -> 2772 bytes .../ontime_clocks_red_digital_inventory.png | Bin 0 -> 315 bytes ontime_clocks/textures/ontime_clocks_white.png | Bin 0 -> 285 bytes .../textures/ontime_clocks_white_inventory.png | Bin 0 -> 534 bytes 20 files changed, 398 insertions(+) create mode 100644 ontime_clocks/LICENSE.txt create mode 100644 ontime_clocks/README.md create mode 100644 ontime_clocks/common.lua create mode 100644 ontime_clocks/crafts.lua create mode 100644 ontime_clocks/depends.txt create mode 100644 ontime_clocks/init.lua create mode 100644 ontime_clocks/nodes.lua create mode 100644 ontime_clocks/textures/ontime_clocks_digital.png create mode 100644 ontime_clocks/textures/ontime_clocks_digital_background.png create mode 100644 ontime_clocks/textures/ontime_clocks_digital_digit.png create mode 100644 ontime_clocks/textures/ontime_clocks_frameless.png create mode 100644 ontime_clocks/textures/ontime_clocks_frameless_inventory.png create mode 100644 ontime_clocks/textures/ontime_clocks_green_digital_inventory.png create mode 100644 ontime_clocks/textures/ontime_clocks_needle_h36.png create mode 100644 ontime_clocks/textures/ontime_clocks_needle_h48.png create mode 100644 ontime_clocks/textures/ontime_clocks_needle_m36.png create mode 100644 ontime_clocks/textures/ontime_clocks_needle_m48.png create mode 100644 ontime_clocks/textures/ontime_clocks_red_digital_inventory.png create mode 100644 ontime_clocks/textures/ontime_clocks_white.png create mode 100644 ontime_clocks/textures/ontime_clocks_white_inventory.png (limited to 'ontime_clocks') diff --git a/ontime_clocks/LICENSE.txt b/ontime_clocks/LICENSE.txt new file mode 100644 index 0000000..bc06764 --- /dev/null +++ b/ontime_clocks/LICENSE.txt @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/ontime_clocks/README.md b/ontime_clocks/README.md new file mode 100644 index 0000000..b62c01a --- /dev/null +++ b/ontime_clocks/README.md @@ -0,0 +1,47 @@ +# Ontime Clocks + +This mod provides clocks that display real ingame time. + +**Dependancies**: display_lib, default + +**License**: WTFPL + +## Recipes + +**Green and red digital clocks** + + - D - + G M G + - - - + +G = Glass, D = Dye, M = Mese Crystal, - = Empty + +Green dye for green clock, red dye for red clock + +**White clock** + + S P S + - M - + - - - + +P = Paper, S = Steel Ingot, M = Mese Crystal, - = Empty + + +**Frameless clock** + + S D S + - M - + - - - + +D = Dye, S = Steel Ingot, M = Mese Crystal, - = Empty + +Black dye for black clock, White dye for white clock + +**Gold frameless clock** + + G - G + - M - + - - - + +G = Gold Ingot, M = Mese Crystal, - = Empty + diff --git a/ontime_clocks/common.lua b/ontime_clocks/common.lua new file mode 100644 index 0000000..6a9681c --- /dev/null +++ b/ontime_clocks/common.lua @@ -0,0 +1,41 @@ +-- Entity for time display +display_lib.register_display_entity("ontime_clocks:display") + +function ontime_clocks.get_h24() + return math.floor(minetest.get_timeofday()*24)%24 +end + +function ontime_clocks.get_h12() + return math.floor(minetest.get_timeofday()*24)%12 +end + +function ontime_clocks.get_m12() + return math.floor(minetest.get_timeofday()*288)%12 +end + +function ontime_clocks.get_digital_properties(color_off, color_on, hour, minute) + return + { + textures={"ontime_clocks_digital_background.png^[colorize:"..color_off + .."^([combine:21x7" + ..":0,"..(-7*(math.floor(hour/10))).."=ontime_clocks_digital_digit.png" + ..":5,"..(-7*(hour%10)).."=ontime_clocks_digital_digit.png" + ..":9,-70=ontime_clocks_digital_digit.png" + ..":12,"..(-7*(math.floor(minute/2))).."=ontime_clocks_digital_digit.png" + ..":17,"..(-35*(minute%2)).."=ontime_clocks_digital_digit.png" + .."^[colorize:"..color_on..")"}, + visual_size = {x=21/32, y=7/32} + } +end + +function ontime_clocks.get_needles_properties(color, size, hour, minute) + return + { + textures={"[combine:"..size.."x"..size + ..":0,"..(-size*hour).."=ontime_clocks_needle_h"..size..".png" + ..":0,"..(-size*minute).."=ontime_clocks_needle_m"..size..".png" + .."^[colorize:"..color}, + visual_size = {x=size/64, y=size/64} + } +end + diff --git a/ontime_clocks/crafts.lua b/ontime_clocks/crafts.lua new file mode 100644 index 0000000..c7e1ab6 --- /dev/null +++ b/ontime_clocks/crafts.lua @@ -0,0 +1,56 @@ + +minetest.register_craft({ + output = 'ontime_clocks:green_digital', + recipe = { + {'', 'dye:green', ''}, + {'default:glass', 'default:mese_crystal', 'default:glass'}, + {'', '', ''}, + } +}) + +minetest.register_craft({ + output = 'ontime_clocks:red_digital', + recipe = { + {'', 'dye:red', ''}, + {'default:glass', 'default:mese_crystal', 'default:glass'}, + {'', '', ''}, + } +}) + +minetest.register_craft({ + output = 'ontime_clocks:white', + recipe = { + {'default:steel_ingot', 'default:paper', 'default:steel_ingot'}, + {'', 'default:mese_crystal', ''}, + {'', '', ''}, + } +}) + +minetest.register_craft({ + output = 'ontime_clocks:frameless_black', + recipe = { + {'default:steel_ingot', 'dye:black', 'default:steel_ingot'}, + {'', 'default:mese_crystal', ''}, + {'', '', ''}, + } +}) + +minetest.register_craft({ + output = 'ontime_clocks:frameless_gold', + recipe = { + {'default:gold_ingot', '', 'default:gold_ingot'}, + {'', 'default:mese_crystal', ''}, + {'', '', ''}, + } +}) + +minetest.register_craft({ + output = 'ontime_clocks:frameless_white', + recipe = { + {'default:steel_ingot', 'dye:white', 'default:steel_ingot'}, + {'', 'default:mese_crystal', ''}, + {'', '', ''}, + } +}) + + diff --git a/ontime_clocks/depends.txt b/ontime_clocks/depends.txt new file mode 100644 index 0000000..c1feb90 --- /dev/null +++ b/ontime_clocks/depends.txt @@ -0,0 +1,3 @@ +default +display_lib + diff --git a/ontime_clocks/init.lua b/ontime_clocks/init.lua new file mode 100644 index 0000000..5210aef --- /dev/null +++ b/ontime_clocks/init.lua @@ -0,0 +1,14 @@ +-- On time clocks mod by P.Y. Rollo +-- +-- License: WTFPL + +ontime_clocks = {} +ontime_clocks.path = minetest.get_modpath("ontime_clocks") + +dofile(ontime_clocks.path.."/common.lua") +dofile(ontime_clocks.path.."/nodes.lua") +dofile(ontime_clocks.path.."/crafts.lua") + + + + diff --git a/ontime_clocks/nodes.lua b/ontime_clocks/nodes.lua new file mode 100644 index 0000000..4a184e8 --- /dev/null +++ b/ontime_clocks/nodes.lua @@ -0,0 +1,224 @@ +-- Green digital clock +minetest.register_node("ontime_clocks:green_digital", { + description = "Green digital clock", + inventory_image = "ontime_clocks_green_digital_inventory.png", + wield_image = "ontime_clocks_green_digital_inventory.png", + paramtype = "light", + paramtype2 = "wallmounted", + drawtype = "nodebox", + node_box = { + type = "wallmounted", + wall_side = { -0.5, -3/16, -7/16, -13/32, 7/32, 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_digital.png"}, + groups = {oddly_breakable_by_hand=1}, + display_entities = { + ["ontime_clocks:display"] = { + depth = -13/32 + 0.01, + on_display_update = function(pos, objref) + objref:set_properties( + ontime_clocks.get_digital_properties( + "#040", "#0F0", ontime_clocks.get_h24(), ontime_clocks.get_m12())) + end }, + }, + on_place = display_lib.on_place, + on_construct = display_lib.on_construct, + on_destruct = display_lib.on_destruct, + on_rotate = display_lib.on_rotate, +}) + +minetest.register_abm({ + nodenames = {"ontime_clocks:green_digital"}, + interval = 5, + chance = 1, + action = display_lib.update_entities, +}) + +-- Red digital clock +minetest.register_node("ontime_clocks:red_digital", { + description = "Red digital clock", + inventory_image = "ontime_clocks_red_digital_inventory.png", + wield_image = "ontime_clocks_red_digital_inventory.png", + paramtype = "light", + paramtype2 = "wallmounted", + drawtype = "nodebox", + node_box = { + type = "wallmounted", + wall_side = { -0.5, -3/16, -7/16, -13/32, 7/32, 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_digital.png"}, + groups = {oddly_breakable_by_hand=1}, + display_entities = { + ["ontime_clocks:display"] = { + depth = -13/32 + 0.01, + on_display_update = function(pos, objref) + objref:set_properties( + ontime_clocks.get_digital_properties( + "#400", "#F00", ontime_clocks.get_h24(), ontime_clocks.get_m12())) + end }, + }, + on_place = display_lib.on_place, + on_construct = display_lib.on_construct, + on_destruct = display_lib.on_destruct, + on_rotate = display_lib.on_rotate, +}) + +minetest.register_abm({ + nodenames = {"ontime_clocks:red_digital"}, + interval = 5, + chance = 1, + action = display_lib.update_entities, +}) + + +minetest.register_node("ontime_clocks:white", { + description = "White clock", + inventory_image = "ontime_clocks_white_inventory.png", + wield_image = "ontime_clocks_white_inventory.png", + paramtype = "light", + paramtype2 = "wallmounted", + drawtype = "nodebox", + node_box = { + type = "wallmounted", + wall_side = { -0.5, -7/16, -7/16, -6/16, 7/16, 7/16}, + wall_bottom = { -7/16, -0.5, -7/16, 7/16, -7/16, 7/16}, + wall_top = { -7/16, 0.5, -7/16, 7/16, 7/16, 7/16}, + }, + tiles = {"ontime_clocks_white.png"}, + groups = {choppy=1,oddly_breakable_by_hand=1}, + display_entities = { + ["ontime_clocks:display"] = { + depth = -6/16+0.01, + on_display_update = function(pos, objref) + objref:set_properties( + ontime_clocks.get_needles_properties( + "#000", 36, ontime_clocks.get_h12(), ontime_clocks.get_m12())) + end }, + }, + on_place = display_lib.on_place, + on_construct = display_lib.on_construct, + on_destruct = display_lib.on_destruct, + on_rotate = display_lib.on_rotate, +}) + +minetest.register_abm({ + nodenames = {"ontime_clocks:white"}, + interval = 5, + chance = 1, + action = display_lib.update_entities, +}) + +minetest.register_node("ontime_clocks:frameless_black", { + description = "Frameless clock", + inventory_image = "ontime_clocks_frameless_inventory.png", + wield_image = "ontime_clocks_frameless_inventory.png", + paramtype = "light", + paramtype2 = "wallmounted", + drawtype = "nodebox", + 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 = {choppy=1,oddly_breakable_by_hand=1}, + 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_lib.on_place, + on_construct = display_lib.on_construct, + on_destruct = display_lib.on_destruct, + on_rotate = display_lib.on_rotate, +}) + +minetest.register_abm({ + nodenames = {"ontime_clocks:frameless_black"}, + interval = 5, + chance = 1, + action = display_lib.update_entities, +}) + +minetest.register_node("ontime_clocks:frameless_gold", { + description = "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", + 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 = {choppy=1,oddly_breakable_by_hand=1}, + 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_lib.on_place, + on_construct = display_lib.on_construct, + on_destruct = display_lib.on_destruct, + on_rotate = display_lib.on_rotate, +}) + +minetest.register_abm({ + nodenames = {"ontime_clocks:frameless_gold"}, + interval = 5, + chance = 1, + action = display_lib.update_entities, +}) + +minetest.register_node("ontime_clocks:frameless_white", { + description = "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", + 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 = {choppy=1,oddly_breakable_by_hand=1}, + 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_lib.on_place, + on_construct = display_lib.on_construct, + on_destruct = display_lib.on_destruct, + on_rotate = display_lib.on_rotate, +}) + +minetest.register_abm({ + nodenames = {"ontime_clocks:frameless_white"}, + interval = 5, + chance = 1, + action = display_lib.update_entities, +}) diff --git a/ontime_clocks/textures/ontime_clocks_digital.png b/ontime_clocks/textures/ontime_clocks_digital.png new file mode 100644 index 0000000..4b79679 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_digital.png differ diff --git a/ontime_clocks/textures/ontime_clocks_digital_background.png b/ontime_clocks/textures/ontime_clocks_digital_background.png new file mode 100644 index 0000000..6731145 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_digital_background.png differ diff --git a/ontime_clocks/textures/ontime_clocks_digital_digit.png b/ontime_clocks/textures/ontime_clocks_digital_digit.png new file mode 100644 index 0000000..7bbc4a9 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_digital_digit.png differ diff --git a/ontime_clocks/textures/ontime_clocks_frameless.png b/ontime_clocks/textures/ontime_clocks_frameless.png new file mode 100644 index 0000000..07c0001 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_frameless.png differ diff --git a/ontime_clocks/textures/ontime_clocks_frameless_inventory.png b/ontime_clocks/textures/ontime_clocks_frameless_inventory.png new file mode 100644 index 0000000..b91c93c Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_frameless_inventory.png differ diff --git a/ontime_clocks/textures/ontime_clocks_green_digital_inventory.png b/ontime_clocks/textures/ontime_clocks_green_digital_inventory.png new file mode 100644 index 0000000..3318f10 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_green_digital_inventory.png differ diff --git a/ontime_clocks/textures/ontime_clocks_needle_h36.png b/ontime_clocks/textures/ontime_clocks_needle_h36.png new file mode 100644 index 0000000..bc1845d Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_needle_h36.png differ diff --git a/ontime_clocks/textures/ontime_clocks_needle_h48.png b/ontime_clocks/textures/ontime_clocks_needle_h48.png new file mode 100644 index 0000000..c894ac5 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_needle_h48.png differ diff --git a/ontime_clocks/textures/ontime_clocks_needle_m36.png b/ontime_clocks/textures/ontime_clocks_needle_m36.png new file mode 100644 index 0000000..90bd878 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_needle_m36.png differ diff --git a/ontime_clocks/textures/ontime_clocks_needle_m48.png b/ontime_clocks/textures/ontime_clocks_needle_m48.png new file mode 100644 index 0000000..4c4a13c Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_needle_m48.png differ diff --git a/ontime_clocks/textures/ontime_clocks_red_digital_inventory.png b/ontime_clocks/textures/ontime_clocks_red_digital_inventory.png new file mode 100644 index 0000000..cfe4fe0 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_red_digital_inventory.png differ diff --git a/ontime_clocks/textures/ontime_clocks_white.png b/ontime_clocks/textures/ontime_clocks_white.png new file mode 100644 index 0000000..577f2d1 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_white.png differ diff --git a/ontime_clocks/textures/ontime_clocks_white_inventory.png b/ontime_clocks/textures/ontime_clocks_white_inventory.png new file mode 100644 index 0000000..03f7b58 Binary files /dev/null and b/ontime_clocks/textures/ontime_clocks_white_inventory.png differ -- cgit v1.2.3