Initial commit.
27
README.md
Normal file
@ -0,0 +1,27 @@
|
||||
24hr Clock [24hr_clock]
|
||||
=======================
|
||||
|
||||
A 24hr clock with one hand.
|
||||
|
||||
David_G (kestral246@gmail.com)
|
||||
|
||||
|
||||
*Based on my hud_compass mod, which provides both a compass and a 24hr clock that can be optionally enabled and placed in any of the four corners of the player's screen.*
|
||||
|
||||
|
||||
Crafting guide
|
||||
--------------
|
||||
|
||||
```
|
||||
, tin_ingot ,
|
||||
copper_ingot, glass , copper_ingot
|
||||
, copper_ingot,
|
||||
```
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
- **new textures:** derived from ccompass, textures CC BY-SA by tacotexmex (changes by kestral246 also CC BY-SA)
|
||||
- **code:** My changes to original code are CC0-1.0
|
||||
- **original compassgps license:** Original code by Echo, PilzAdam, and TeTpaAka is WTFPL. Kilarin (Donald Hines) changes are CC0 (No rights reserved)
|
||||
|
93
init.lua
Normal file
@ -0,0 +1,93 @@
|
||||
-- 24hr_clock
|
||||
-- By David_G (kestral246@gmail.com)
|
||||
|
||||
local activewidth=8 -- Number of inventory slots to check.
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local players = minetest.get_connected_players()
|
||||
for i,player in ipairs(players) do
|
||||
local gotaclock=false
|
||||
local wielded=false
|
||||
local activeinv=nil
|
||||
local stackidx=0
|
||||
local wielded_item = player:get_wielded_item():get_name()
|
||||
if string.sub(wielded_item, 0, 16) == "24hr_clock:clock" then
|
||||
wielded=true
|
||||
stackidx=player:get_wield_index()
|
||||
gotaclock=true
|
||||
else
|
||||
if player:get_inventory() then
|
||||
for i,stack in ipairs(player:get_inventory():get_list("main")) do
|
||||
if i<=activewidth and string.sub(stack:get_name(), 0, 16) == "24hr_clock:clock" then
|
||||
activeinv=stack
|
||||
stackidx=i
|
||||
gotaclock=true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if gotaclock then
|
||||
local clock_image = math.floor(24 * minetest.get_timeofday())
|
||||
|
||||
if wielded then
|
||||
player:set_wielded_item("24hr_clock:clock"..clock_image)
|
||||
elseif activeinv then
|
||||
player:get_inventory():set_stack("main",stackidx,"24hr_clock:clock"..clock_image)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local images = {
|
||||
"24hr_clock_0.png",
|
||||
"24hr_clock_1.png",
|
||||
"24hr_clock_2.png",
|
||||
"24hr_clock_3.png",
|
||||
"24hr_clock_4.png",
|
||||
"24hr_clock_5.png",
|
||||
"24hr_clock_6.png",
|
||||
"24hr_clock_7.png",
|
||||
"24hr_clock_8.png",
|
||||
"24hr_clock_9.png",
|
||||
"24hr_clock_10.png",
|
||||
"24hr_clock_11.png",
|
||||
"24hr_clock_12.png",
|
||||
"24hr_clock_13.png",
|
||||
"24hr_clock_14.png",
|
||||
"24hr_clock_15.png",
|
||||
"24hr_clock_16.png",
|
||||
"24hr_clock_17.png",
|
||||
"24hr_clock_18.png",
|
||||
"24hr_clock_19.png",
|
||||
"24hr_clock_20.png",
|
||||
"24hr_clock_21.png",
|
||||
"24hr_clock_22.png",
|
||||
"24hr_clock_23.png",
|
||||
}
|
||||
|
||||
local i
|
||||
for i,img in ipairs(images) do
|
||||
local inv = 1
|
||||
if i == 12 then
|
||||
inv = 0
|
||||
end
|
||||
minetest.register_tool("24hr_clock:clock"..(i-1), {
|
||||
description = "24-Hour Clock",
|
||||
inventory_image = img,
|
||||
wield_image = img,
|
||||
groups = {not_in_creative_inventory=inv}
|
||||
})
|
||||
end
|
||||
|
||||
-- crafting recipe only works if default mod present.
|
||||
if minetest.get_modpath("default") ~= nil then
|
||||
minetest.register_craft({
|
||||
output = '24hr_clock:clock12',
|
||||
recipe = {
|
||||
{'', 'default:tin_ingot', ''},
|
||||
{'default:copper_ingot', 'default:glass', 'default:copper_ingot'},
|
||||
{'', 'default:copper_ingot', ''}
|
||||
}
|
||||
})
|
||||
end
|
3
mod.conf
Normal file
@ -0,0 +1,3 @@
|
||||
name = 24hr_clock
|
||||
description = A 24-hour clock with a single hand.
|
||||
optional_depends = default
|
BIN
textures/24hr_clock_0.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_1.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_10.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_11.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_12.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_13.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_14.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_15.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_16.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_17.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_18.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_19.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_2.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_20.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_21.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_22.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_23.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_3.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_4.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_5.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_6.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_7.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_8.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/24hr_clock_9.png
Normal file
After Width: | Height: | Size: 2.3 KiB |