diff --git a/mods/DOM/watch/itens.lua b/mods/DOM/watch/itens.lua index 181f0ed2eb..d35ec798b9 100644 --- a/mods/DOM/watch/itens.lua +++ b/mods/DOM/watch/itens.lua @@ -12,9 +12,15 @@ minetest.register_craft({ --Watch tool -watch.registra_item("watch:watch",watch.images_a[3],true) +watch.registra_item("watch:watch",watch.images[3],true) --Faces -for a=0,11,1 do - watch.registra_item("watch:watch_a"..tostring(a),watch.images_a[a+1],false) +for a=0,63,1 do + local b = a + if b > 31 then + b = b - 32 + else + b = b + 32 + end + watch.registra_item("watch:watch_"..tostring(a),watch.images[b+1],false) end diff --git a/mods/DOM/watch/rotinas.lua b/mods/DOM/watch/rotinas.lua index f84ab1c633..c8e6033254 100644 --- a/mods/DOM/watch/rotinas.lua +++ b/mods/DOM/watch/rotinas.lua @@ -7,87 +7,19 @@ watch = {} watch.ultimo_tempo = -1 --- Image of all 12 possible faces, only cover hours, a day is to short to lost time with game minutes... :-P -watch.images_a = { - "watch_a0.png", - "watch_a1.png", - "watch_a2.png", - "watch_a3.png", - "watch_a4.png", - "watch_a5.png", - "watch_a6.png", - "watch_a7.png", - "watch_a8.png", - "watch_a9.png", - "watch_a10.png", - "watch_a11.png", -} -watch.images_d={ - "watch_d0.png", - "watch_d1.png", - "watch_d2.png", - "watch_d3.png", - "watch_d4.png", - "watch_d5.png", - "watch_d6.png", - "watch_d7.png", - "watch_d8.png", - "watch_d9.png", - "watch_d10.png", - "watch_d11.png", -} - ---Catch the sever time and convert to hour, 12000 = 12h = 0.5, 6000 = 6h = 0.25 -function watch.pega_hora(tipo) - local tempo_r = "12:00" - local t = minetest.env:get_timeofday() - local tempo = t*24 -- Get the time - local tempo_h = math.floor(tempo) -- Get 24h only, losting minutes - local tempo_m =math.floor((tempo - tempo_h)*60) --Get only minutes - - --Hour - local tempo_h_12 = tempo_h - if tempo_h > 12 then -- Converte time to time in 12h format - tempo_h_12 = tempo_h - 12 - end - - if tipo==2 then -- hh - return(tostring(tempo_h_12)) - end - - tempo_r = tostring(tempo_h) .. ":" - - --Minutes - if tempo_m < 10 then -- Add a zero at left if need. - tempo_r = tempo_r .. "0" - end - tempo_r = tempo_r .. tostring(tempo_m) - - return(tempo_r) --HH:MM +-- Image of all 64 possible faces +watch.images = {} +for frame=0,63 do + table.insert(watch.images, "clock_clock.png^[verticalframe:64:"..frame) end ---When someone try use the watch. -function watch.usa (itemstack, user, pointed_thing) - item=itemstack:to_table() - local meta=DOM_get_item_meta(item) - local w_type="a" +local function round(num) + return math.floor(num + 0.5) +end - if meta~=nil then - w_type = meta["w_type"] - end - ---DOM_inspeciona_r("Valores no meta:"..dump(meta)) - --print("Relógio em modo: "..w_type) - meta["time"] = watch.pega_hora(1) - meta["w_type"] = w_type - DOM_set_item_meta(item, meta) - meta=DOM_get_item_meta(item) ---DOM_inspeciona_r("Valores no meta:"..dump(meta)) - minetest.chat_send_player(user:get_player_name(), "[Watch] Time now is:" .. meta["time"]) - - itemstack:replace(item) - - return itemstack +function watch.pega_hora() + local t = 64 * minetest.get_timeofday() + return tostring(round(t)) end -- Register itens @@ -97,7 +29,6 @@ function watch.registra_item(nome,imagem,aparece_nas_receitas) g = 0 end ---DOM_inspeciona_r("Registrando item "..nome..","..imagem) minetest.register_tool(nome, { description = "Clock", inventory_image = imagem, @@ -105,34 +36,29 @@ function watch.registra_item(nome,imagem,aparece_nas_receitas) metadata = {w_type="d"}, wield_image = "", stack_max = 1, - on_use = watch.usa, }) end minetest.register_globalstep(function(dtime) - local t="a" -- d to digital, a to analogic - local now = watch.pega_hora(2) ---DOM_inspeciona_r("Hora:"..now) - if now == "12" then now = "0" end + local now = watch.pega_hora() if watch.ultimo_tempo == now then - return +-- return end watch.ultimo_tempo = now - - local players = minetest.get_connected_players() + local players = minetest.get_connected_players() for i,player in ipairs(players) do - if string.sub(player:get_wielded_item():get_name(), 0, 11) == "watch:watch" then - player:set_wielded_item("watch:watch_"..t..now) + if string.sub(player:get_wielded_item():get_name(), 0, 63) == "watch:watch" then + player:set_wielded_item("watch:watch_"..now) end for i,stack in ipairs(player:get_inventory():get_list("main")) do - if i<9 and string.sub(stack:get_name(), 0, 11) == "watch:watch" then + if i<10 and string.sub(stack:get_name(), 0, 11) == "watch:watch" then player:get_inventory():remove_item("main", stack:get_name()) - player:get_inventory():add_item("main", "watch:watch_"..t..now) + player:get_inventory():add_item("main", "watch:watch_"..now) end end end diff --git a/mods/DOM/watch/textures/clock_clock.png b/mods/DOM/watch/textures/clock_clock.png new file mode 100644 index 0000000000..f81fb7d47e Binary files /dev/null and b/mods/DOM/watch/textures/clock_clock.png differ diff --git a/mods/DOM/watch/textures/watch_a0.png b/mods/DOM/watch/textures/watch_a0.png deleted file mode 100644 index d9716b2f84..0000000000 Binary files a/mods/DOM/watch/textures/watch_a0.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a1.png b/mods/DOM/watch/textures/watch_a1.png deleted file mode 100644 index 87185bb3c5..0000000000 Binary files a/mods/DOM/watch/textures/watch_a1.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a10.png b/mods/DOM/watch/textures/watch_a10.png deleted file mode 100644 index 7de6171b34..0000000000 Binary files a/mods/DOM/watch/textures/watch_a10.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a11.png b/mods/DOM/watch/textures/watch_a11.png deleted file mode 100644 index 506a05e280..0000000000 Binary files a/mods/DOM/watch/textures/watch_a11.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a2.png b/mods/DOM/watch/textures/watch_a2.png deleted file mode 100644 index 2cfddeae4d..0000000000 Binary files a/mods/DOM/watch/textures/watch_a2.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a3.png b/mods/DOM/watch/textures/watch_a3.png deleted file mode 100644 index 726a1ca753..0000000000 Binary files a/mods/DOM/watch/textures/watch_a3.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a4.png b/mods/DOM/watch/textures/watch_a4.png deleted file mode 100644 index fe10ebdb45..0000000000 Binary files a/mods/DOM/watch/textures/watch_a4.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a5.png b/mods/DOM/watch/textures/watch_a5.png deleted file mode 100644 index 6d176ea6f9..0000000000 Binary files a/mods/DOM/watch/textures/watch_a5.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a6.png b/mods/DOM/watch/textures/watch_a6.png deleted file mode 100644 index 5eecec8a15..0000000000 Binary files a/mods/DOM/watch/textures/watch_a6.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a7.png b/mods/DOM/watch/textures/watch_a7.png deleted file mode 100644 index 16332d0806..0000000000 Binary files a/mods/DOM/watch/textures/watch_a7.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a8.png b/mods/DOM/watch/textures/watch_a8.png deleted file mode 100644 index 6690e53f18..0000000000 Binary files a/mods/DOM/watch/textures/watch_a8.png and /dev/null differ diff --git a/mods/DOM/watch/textures/watch_a9.png b/mods/DOM/watch/textures/watch_a9.png deleted file mode 100644 index 07055561fc..0000000000 Binary files a/mods/DOM/watch/textures/watch_a9.png and /dev/null differ