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
43
init.lua
43
init.lua
@ -1,5 +1,9 @@
|
||||
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 = {}
|
||||
|
||||
@ -305,11 +309,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
-- Traitement du bouton de transfert
|
||||
if fields.transfer then
|
||||
-- Supprimer les éléments de récupération du joueur
|
||||
for i = 1, player_inv:get_size("main") do
|
||||
local stack = player_inv:get_stack("main", i)
|
||||
if stack:get_name():find("mcl_compass:.*_recovery") then
|
||||
player_inv:remove_item("main", stack)
|
||||
if setting_give_recovery_compass == true then
|
||||
-- Supprimer les éléments de récupération du joueur
|
||||
for i = 1, player_inv:get_size("main") do
|
||||
local stack = player_inv:get_stack("main", i)
|
||||
if stack:get_name():find("mcl_compass:.*_recovery") then
|
||||
player_inv:remove_item("main", stack)
|
||||
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
|
||||
compass_frames = 32
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
-- Generate a new random frame for the recovery compass
|
||||
local random_frame = math.random(0, compass_frames - 1)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
-- Generate a new random frame for the recovery compass
|
||||
local random_frame = math.random(0, compass_frames - 1)
|
||||
-- Create the recovery compass item
|
||||
local recovery_compass = ItemStack("mcl_compass:" .. random_frame .. "_recovery")
|
||||
local player_inv_2 = player:get_inventory()
|
||||
|
||||
-- Create the recovery compass item
|
||||
local recovery_compass = ItemStack("mcl_compass:" .. random_frame .. "_recovery")
|
||||
local player_inv_2 = player:get_inventory()
|
||||
if player_inv_2 then
|
||||
player_inv_2:add_item("main", recovery_compass)
|
||||
end
|
||||
|
||||
if player_inv_2 then
|
||||
player_inv_2:add_item("main", recovery_compass)
|
||||
end
|
||||
|
||||
end)
|
||||
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