Merge pull request 'Make recovery compass optional' (#1) from chud/recovery_coffre:optional_compass into main
Reviewed-on: https://codeberg.org/neocraft1293/recovery_coffre/pulls/1
This commit is contained in:
commit
0cbc0811f4
45
init.lua
45
init.lua
@ -1,5 +1,9 @@
|
|||||||
local S = minetest.get_translator("chest_recovery") -- Récupérer le traducteur pour ce mod
|
local S = minetest.get_translator("chest_recovery") -- Récupérer le traducteur pour ce mod
|
||||||
|
|
||||||
|
-- settings
|
||||||
|
|
||||||
|
local setting_give_recovery_compass = minetest.settings:get_bool("chest_recovery_give_recovery_compass", false)
|
||||||
|
|
||||||
|
|
||||||
chest_positions = {}
|
chest_positions = {}
|
||||||
|
|
||||||
@ -305,11 +309,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
|
|
||||||
-- Traitement du bouton de transfert
|
-- Traitement du bouton de transfert
|
||||||
if fields.transfer then
|
if fields.transfer then
|
||||||
-- Supprimer les éléments de récupération du joueur
|
if setting_give_recovery_compass == true then
|
||||||
for i = 1, player_inv:get_size("main") do
|
-- Supprimer les éléments de récupération du joueur
|
||||||
local stack = player_inv:get_stack("main", i)
|
for i = 1, player_inv:get_size("main") do
|
||||||
if stack:get_name():find("mcl_compass:.*_recovery") then
|
local stack = player_inv:get_stack("main", i)
|
||||||
player_inv:remove_item("main", stack)
|
if stack:get_name():find("mcl_compass:.*_recovery") then
|
||||||
|
player_inv:remove_item("main", stack)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -546,23 +552,24 @@ minetest.register_privilege("chest_recovery_bypass", {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if setting_give_recovery_compass == true then
|
||||||
|
-- Define compass_frames as a global variable
|
||||||
|
compass_frames = 32
|
||||||
|
|
||||||
-- Define compass_frames as a global variable
|
minetest.register_on_respawnplayer(function(player)
|
||||||
compass_frames = 32
|
-- Generate a new random frame for the recovery compass
|
||||||
|
local random_frame = math.random(0, compass_frames - 1)
|
||||||
|
|
||||||
minetest.register_on_respawnplayer(function(player)
|
-- Create the recovery compass item
|
||||||
-- Generate a new random frame for the recovery compass
|
local recovery_compass = ItemStack("mcl_compass:" .. random_frame .. "_recovery")
|
||||||
local random_frame = math.random(0, compass_frames - 1)
|
local player_inv_2 = player:get_inventory()
|
||||||
|
|
||||||
-- Create the recovery compass item
|
if player_inv_2 then
|
||||||
local recovery_compass = ItemStack("mcl_compass:" .. random_frame .. "_recovery")
|
player_inv_2:add_item("main", recovery_compass)
|
||||||
local player_inv_2 = player:get_inventory()
|
end
|
||||||
|
|
||||||
if player_inv_2 then
|
end)
|
||||||
player_inv_2:add_item("main", recovery_compass)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -599,4 +606,4 @@ minetest.register_privilege("chest_recovery_bypass", {
|
|||||||
return true, "Coffre ouvert à distance."
|
return true, "Coffre ouvert à distance."
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
2
settingtypes.txt
Normal file
2
settingtypes.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# give player a recovery compass on death, and delete it on recovery
|
||||||
|
chest_recovery_give_recovery_compass (Recovery Compass) bool false
|
Loading…
x
Reference in New Issue
Block a user