Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions display_api/display.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ local function get_orientation_values(node)
local paramtype2 = ndef.paramtype2
if paramtype2 == "wallmounted" or paramtype2 == "colorwallmounted" then
return wallmounted_values[node.param2 % 8]
elseif paramtype2 == "facedir" or paramtype2 == "colorfacedir" then
elseif paramtype2 == "facedir" or paramtype2 == "colorfacedir" then
return facedir_values[node.param2 % 32]
else
-- No orientation or unknown orientation type
Expand Down Expand Up @@ -147,7 +147,8 @@ 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 depth = clip_pos_prop(edef.depth)
local right = clip_pos_prop(edef.right)
local top = clip_pos_prop(edef.top)
Expand All @@ -160,14 +161,19 @@ 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
minetest.log("warning", string.format(
"[display_api] unable to rotate correctly entity for node at %s without set_rotation method.",
"[display_api] unable to rotate correctly entity for " ..
"node at %s without set_rotation method.",
minetest.pos_to_string(pos)))
end
objref:set_yaw(ov.rotation.y*math.pi/2 + (edef.yaw or 0))
Expand Down Expand Up @@ -229,7 +235,7 @@ function display_api.on_place(itemstack, placer, pointed_thing, override_param2)
param2 = minetest.dir_to_wallmounted(dir)

elseif ndef.paramtype2 == "facedir" or
ndef.paramtype2 == "colorfacedir" then
ndef.paramtype2 == "colorfacedir" then
param2 = minetest.dir_to_facedir(dir, true)
end
end
Expand Down Expand Up @@ -276,31 +282,35 @@ 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
minetest.register_entity(':'..entity_name, {
initial_properties = {
collisionbox = {0, 0, 0, 0, 0, 0},
visual = "upright_sprite",
textures = {},
collide_with_objects = false,
pointable = false
},
on_activate = display_api.on_activate,
get_staticdata = function(self)
return minetest.serialize({ nodepos = self.nodepos })
end,
on_blast = function(self, damage)
return false, false, {}
end,
})

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,
},
on_activate = display_api.on_activate,
get_staticdata = function(self)
return minetest.serialize({ nodepos = self.nodepos })
end,
on_blast = function(self, damage)
return false, false, {}
end,
})
end

minetest.register_lbm({
label = "Update display_api entities",
name = "display_api:update_entities",
run_at_every_load = true,
nodenames = {"group:display_api",
"group:display_modpack_node", "group:display_lib_node"}, -- See deprecated(1)
"group:display_modpack_node",
"group:display_lib_node"}, -- See deprecated(1)
action = function(pos, node) display_api.update_entities(pos) end,
})
7 changes: 5 additions & 2 deletions ontime_clocks/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -58,4 +62,3 @@ function ontime_clocks.get_needles_properties(color, size, hour, minute)
visual_size = {x=size/64, y=size/64}
}
end

53 changes: 53 additions & 0 deletions ontime_clocks/crafts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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', ''},
{'', '', ''},
}
})

112 changes: 112 additions & 0 deletions ontime_clocks/design/ontime_clocks_large_clock_inventory.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading