From 37f256648b1c34f5595250a55e3aa78e4b306ac1 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 5 Jan 2021 12:40:29 +0100 Subject: [PATCH] Fix enchanting book animation being weird sometimes --- mods/ITEMS/mcl_enchanting/engine.lua | 6 +++--- mods/ITEMS/mcl_enchanting/init.lua | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index ead8bb6e..ab42f5d9 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -279,7 +279,7 @@ function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_leve if weights[enchantment] >= r then selected_enchantment = enchantment break - end + end end local enchantment_def = mcl_enchanting.enchantments[selected_enchantment] local power_range_table = enchantment_def.power_range_table @@ -340,7 +340,7 @@ end function mcl_enchanting.get_random_glyph_row() local glyphs = "" local x = 1.3 - for i = 1, 9 do + for i = 1, 9 do glyphs = glyphs .. "image[".. x .. ",0.1;0.5,0.5;mcl_enchanting_glyph_" .. math.random(18) .. ".png^[colorize:#675D49:255]" x = x + 0.6 end @@ -560,7 +560,7 @@ end function mcl_enchanting.set_book_animation(self, anim) local anim_index = mcl_enchanting.book_animations[anim] local start, stop = mcl_enchanting.book_animation_steps[anim_index], mcl_enchanting.book_animation_steps[anim_index + 1] - self.object:set_animation({x = start, y = stop}, mcl_enchanting.book_animation_speed) + self.object:set_animation({x = start, y = stop}, mcl_enchanting.book_animation_speed, 0, mcl_enchanting.book_animation_loop[anim] or false) self.scheduled_anim = nil self.anim_length = (stop - start) / 40 end diff --git a/mods/ITEMS/mcl_enchanting/init.lua b/mods/ITEMS/mcl_enchanting/init.lua index 239eb52a..5735bfb3 100644 --- a/mods/ITEMS/mcl_enchanting/init.lua +++ b/mods/ITEMS/mcl_enchanting/init.lua @@ -5,6 +5,7 @@ mcl_enchanting = { book_offset = vector.new(0, 0.75, 0), book_animations = {["close"] = 1, ["opening"] = 2, ["open"] = 3, ["closing"] = 4}, book_animation_steps = {0, 640, 680, 700, 740}, + book_animation_loop = {["open"] = true, ["close"] = true}, book_animation_speed = 40, roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49 enchantments = {}, @@ -278,7 +279,7 @@ minetest.register_node("mcl_enchanting:table", { drop = "", _mcl_blast_resistance = 1200, _mcl_hardness = 5, -}) +}) minetest.register_craft({ output = "mcl_enchanting:table", @@ -330,7 +331,7 @@ minetest.register_abm({ end end end -}) +}) minetest.register_lbm({ label = "(Re-)spawn book entity above enchanting table", @@ -348,4 +349,4 @@ minetest.register_on_joinplayer(mcl_enchanting.initialize_player) minetest.register_on_player_receive_fields(mcl_enchanting.handle_formspec_fields) minetest.register_allow_player_inventory_action(mcl_enchanting.allow_inventory_action) minetest.register_on_player_inventory_action(mcl_enchanting.on_inventory_action) -table.insert(tt.registered_snippets, 1, mcl_enchanting.enchantments_snippet) +table.insert(tt.registered_snippets, 1, mcl_enchanting.enchantments_snippet)