aboutsummaryrefslogtreecommitdiff
path: root/ontime_clocks
diff options
context:
space:
mode:
authorPierre-Yves Rollo <dev@pyrollo.com>2015-11-11 14:26:39 +0100
committerPierre-Yves Rollo <dev@pyrollo.com>2015-11-11 14:26:39 +0100
commitd44bf53ea20136221d605e139f2b58328b68ce9c (patch)
tree4f747301de219c9743b19efe536f340af90ce5ff /ontime_clocks
downloaddisplay_modpack-d44bf53ea20136221d605e139f2b58328b68ce9c.tar.gz
display_modpack-d44bf53ea20136221d605e139f2b58328b68ce9c.tar.bz2
display_modpack-d44bf53ea20136221d605e139f2b58328b68ce9c.zip
First commit
Diffstat (limited to 'ontime_clocks')
-rw-r--r--ontime_clocks/LICENSE.txt13
-rw-r--r--ontime_clocks/README.md47
-rw-r--r--ontime_clocks/common.lua41
-rw-r--r--ontime_clocks/crafts.lua56
-rw-r--r--ontime_clocks/depends.txt3
-rw-r--r--ontime_clocks/init.lua14
-rw-r--r--ontime_clocks/nodes.lua224
-rw-r--r--ontime_clocks/textures/ontime_clocks_digital.pngbin0 -> 208 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_digital_background.pngbin0 -> 197 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_digital_digit.pngbin0 -> 223 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_frameless.pngbin0 -> 241 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_frameless_inventory.pngbin0 -> 426 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_green_digital_inventory.pngbin0 -> 300 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_needle_h36.pngbin0 -> 1533 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_needle_h48.pngbin0 -> 2517 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_needle_m36.pngbin0 -> 1902 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_needle_m48.pngbin0 -> 2772 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_red_digital_inventory.pngbin0 -> 315 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_white.pngbin0 -> 285 bytes
-rw-r--r--ontime_clocks/textures/ontime_clocks_white_inventory.pngbin0 -> 534 bytes
20 files changed, 398 insertions, 0 deletions
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 <sam@hocevar.net>
+
+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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_digital.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_digital_background.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_digital_digit.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_frameless.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_frameless_inventory.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_green_digital_inventory.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_needle_h36.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_needle_h48.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_needle_m36.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_needle_m48.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_red_digital_inventory.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_white.png
Binary files 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
--- /dev/null
+++ b/ontime_clocks/textures/ontime_clocks_white_inventory.png
Binary files differ