forked from VoxeLibre/VoxeLibre
Fix enchanting book animation being weird sometimes
This commit is contained in:
parent
ebc2ec9f72
commit
37f256648b
|
@ -279,7 +279,7 @@ function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_leve
|
||||||
if weights[enchantment] >= r then
|
if weights[enchantment] >= r then
|
||||||
selected_enchantment = enchantment
|
selected_enchantment = enchantment
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local enchantment_def = mcl_enchanting.enchantments[selected_enchantment]
|
local enchantment_def = mcl_enchanting.enchantments[selected_enchantment]
|
||||||
local power_range_table = enchantment_def.power_range_table
|
local power_range_table = enchantment_def.power_range_table
|
||||||
|
@ -340,7 +340,7 @@ end
|
||||||
function mcl_enchanting.get_random_glyph_row()
|
function mcl_enchanting.get_random_glyph_row()
|
||||||
local glyphs = ""
|
local glyphs = ""
|
||||||
local x = 1.3
|
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]"
|
glyphs = glyphs .. "image[".. x .. ",0.1;0.5,0.5;mcl_enchanting_glyph_" .. math.random(18) .. ".png^[colorize:#675D49:255]"
|
||||||
x = x + 0.6
|
x = x + 0.6
|
||||||
end
|
end
|
||||||
|
@ -560,7 +560,7 @@ end
|
||||||
function mcl_enchanting.set_book_animation(self, anim)
|
function mcl_enchanting.set_book_animation(self, anim)
|
||||||
local anim_index = mcl_enchanting.book_animations[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]
|
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.scheduled_anim = nil
|
||||||
self.anim_length = (stop - start) / 40
|
self.anim_length = (stop - start) / 40
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@ mcl_enchanting = {
|
||||||
book_offset = vector.new(0, 0.75, 0),
|
book_offset = vector.new(0, 0.75, 0),
|
||||||
book_animations = {["close"] = 1, ["opening"] = 2, ["open"] = 3, ["closing"] = 4},
|
book_animations = {["close"] = 1, ["opening"] = 2, ["open"] = 3, ["closing"] = 4},
|
||||||
book_animation_steps = {0, 640, 680, 700, 740},
|
book_animation_steps = {0, 640, 680, 700, 740},
|
||||||
|
book_animation_loop = {["open"] = true, ["close"] = true},
|
||||||
book_animation_speed = 40,
|
book_animation_speed = 40,
|
||||||
roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49
|
roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49
|
||||||
enchantments = {},
|
enchantments = {},
|
||||||
|
@ -278,7 +279,7 @@ minetest.register_node("mcl_enchanting:table", {
|
||||||
drop = "",
|
drop = "",
|
||||||
_mcl_blast_resistance = 1200,
|
_mcl_blast_resistance = 1200,
|
||||||
_mcl_hardness = 5,
|
_mcl_hardness = 5,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mcl_enchanting:table",
|
output = "mcl_enchanting:table",
|
||||||
|
@ -330,7 +331,7 @@ minetest.register_abm({
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_lbm({
|
minetest.register_lbm({
|
||||||
label = "(Re-)spawn book entity above enchanting table",
|
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_on_player_receive_fields(mcl_enchanting.handle_formspec_fields)
|
||||||
minetest.register_allow_player_inventory_action(mcl_enchanting.allow_inventory_action)
|
minetest.register_allow_player_inventory_action(mcl_enchanting.allow_inventory_action)
|
||||||
minetest.register_on_player_inventory_action(mcl_enchanting.on_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)
|
||||||
|
|
Loading…
Reference in New Issue