Page 1 of 1

[Mod] Real Clocks [realclocks]

PostPosted: Tue Mar 03, 2015 17:21
by jp
Game-time based, functional clocks. Updated every hour.
Video Review (by Nathan Salapat) : https://www.youtube.com/watch?v=qs5Va7QzJvM

License : WTFPL (textures and model by VanessaE)

[Download]

Image Image

Re: [Mod] Real Clocks [realclocks]

PostPosted: Tue Mar 03, 2015 18:31
by Krock
With a better texture resolution, you could add numbers :)

Re: [Mod] Real Clocks [realclocks]

PostPosted: Tue Mar 03, 2015 18:37
by jp
I know but won't because of laziness.

Re: [Mod] Real Clocks [realclocks]

PostPosted: Wed Mar 04, 2015 20:21
by Nathan.S
Really nice, but at the moment I see no way to tell if it is am or pm? could such a feature be added, maybe changing the background color of the clock?

Re: [Mod] Real Clocks [realclocks]

PostPosted: Wed Mar 04, 2015 20:33
by jp
Sorry, don't expect any work on that mod in the future ;)

Re: [Mod] Real Clocks [realclocks]

PostPosted: Wed Mar 04, 2015 20:56
by Nathan.S
Would you mind if I tried to add such a feature. I'll just put a zip file here with my version?

Re: [Mod] Real Clocks [realclocks]

PostPosted: Wed Mar 04, 2015 21:06
by jp
No problem, you're totally free to do what you want.

Re: [Mod] Real Clocks [realclocks]

PostPosted: Fri Mar 06, 2015 20:29
by Hybrid Dog
l could change this mod that you can change the time by clicking on a specific position of the clock…

Re: [Mod] Real Clocks [realclocks]

PostPosted: Fri Mar 06, 2015 21:37
by jp
Hybrid Dog wrote:l could change this mod that you can change the time by clicking on a specific position of the clock…

I guess you would use an entity, right ? All initiatives are welcome.

Re: [Mod] Real Clocks [realclocks]

PostPosted: Sat Mar 07, 2015 07:06
by Hybrid Dog
jp wrote:
Hybrid Dog wrote:l could change this mod that you can change the time by clicking on a specific position of the clock…

I guess you would use an entity, right ?

no

Re: [Mod] Real Clocks [realclocks]

PostPosted: Sat Mar 07, 2015 09:08
by Hybrid Dog
l wanted to do something like this
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local clock_cbox = {
   type = "fixed",
   fixed = {
      { -1/4, -3/32, 7/16, 1/4, 3/32, .5 },
      { -7/32, -5/32, 7/16, 7/32, 5/32, .5 },
      { -3/16, -3/16, 7/16, 3/16, 3/16, .5 },
      { -5/32, -7/32, 7/16, 5/32, 7/32, .5 },
      { -3/32, -1/4, 7/16, 3/32, 1/4, .5 }
   }
}

local clock_sbox = {
   type = "fixed",
   fixed = { -1/4, -1/4, 7/16, 1/4, 1/4, .5 }
}

local materials = {"plastic", "wood"}

for _,m in ipairs(materials) do

minetest.register_node("realclocks:analog_clock_"..m.."_12", {
   drawtype = "mesh",
   description = "Analog "..m.." clock",
   mesh = "realclocks_analog_clock.obj",
   paramtype = "light",
   paramtype2 = "facedir",
   sunlight_propagates = true,
   tiles = { "realclocks_analog_clock_"..m..".png^clock_12.png" },
   inventory_image = "realclocks_analog_clock_"..m.."_inv.png",
   wield_image = "realclocks_analog_clock_"..m.."_inv.png",
   collision_box = clock_cbox,
   selection_box = clock_sbox,
   groups = {snappy=3},
})

minetest.register_craft({
    output = "realclocks:analog_clock_"..m.."_12",
    recipe = {
      { "", "dye:black", "" },
      { "", "default:stick", "" },
      { "", "dye:black", "" },
    },
})

for i = 1,11 do

   minetest.register_node("realclocks:analog_clock_"..m.."_"..i, {
      drawtype = "mesh",
      mesh = "realclocks_analog_clock.obj",
      paramtype = "light",
      paramtype2 = "facedir",
      sunlight_propagates = true,
      tiles = { "realclocks_analog_clock_"..m..".png^clock_"..i..".png" },
      collision_box = clock_cbox,
      selection_box = clock_sbox,
      groups = {snappy=3, not_in_creative_inventory=1},
      drop = "realclocks:analog_clock_"..m.."_12",
      on_punch = function(pos, node, puncher, pt)
         minetest.chat_send_all("k…")
         local dir = puncher:get_look_dir()
         local dist = vector.new(dir)

         local plpos = puncher:getpos()
         plpos.y = plpos.y+1.625

         if node.param2 == 0 then
            local shpos = {x=pos.x, y=pos.y, z=pos.z+7/16}

            dist.z = shpos.z-plpos.z
            local m = dist.z/dir.z
            dist.x = dist.x*m
            dist.y = dist.y*m
            local newp = vector.add(plpos, dist)
            local tp = vector.subtract(newp, shpos)
            local newtime = 0.25+math.acos(-tp.y/math.hypot(tp.x, tp.y))/(4*math.pi)
            local oldtime = minetest.get_timeofday()
            if oldtime < 0.25
            or oldtime > 0.75
            or oldtime > newtime then
               newtime = (0.5+newtime)%1
            end
            minetest.chat_send_all("time "..newtime*24)
            minetest.set_timeofday(newtime)
         end
         minetest.chat_send_all("it works again")
      end,
   })

end

for n = 1,12 do

   minetest.register_abm({
      nodenames = { "realclocks:analog_clock_"..m.."_"..n },
      interval = math.min(60, (3600 / (tonumber(minetest.setting_get("time_speed")))) / 3),
      chance = 1,
      action = function(pos, node, active_object_count, active_object_count_wider)
         local hour = minetest.get_timeofday() * 24
         if hour > 12 then
            hour = hour - 12
         end
         hour = math.ceil(hour)
         if hour < 1 then
            hour = 1
         elseif hour > 12 then
            hour = 12
         end
         if node.name ~= "realclocks:analog_clock_"..m.."_"..hour then
            local fdir = minetest.get_node(pos).param2
            minetest.set_node(pos, {name="realclocks:analog_clock_"..m.."_"..hour, param2=fdir})
         end
      end
   })
   
end
end

But the code is unfinished because suddenly on_punch stopped working for me.
l tried to let it say chat messages and punched it the whole time but no message appeared.
But the on_punch of other nodes worked without problems.

EDIT: sorry, my mistake, l forgot 2 (1 of each material) nodes

Re: [Mod] Real Clocks [realclocks]

PostPosted: Sat Mar 07, 2015 11:11
by jp
As improvement, I'm further expecting an animated entity, with 12 frames (= one per hour), with commands to switch the hours - instead of using 22 nodes.

If someone do that, his work will get merged and credited in Home Decor ;)

Re: [Mod] Real Clocks [realclocks]

PostPosted: Fri Mar 13, 2015 15:56
by Hybrid Dog
I made it possible to change time with the clock(s). Someone with settime priv needs to punch it holding aux1 (the fast key)
https://github.com/HybridDog/realclocks