Remove config dependency
This commit is contained in:
parent
b3d874f601
commit
5a8c7bcea6
@ -9,6 +9,8 @@ The receiver can dig the gift box and gets a random item.
|
||||
Note the placer cannot receive their own gift, if they dig the gift
|
||||
box, they will get the gift box back, not its random item.
|
||||
|
||||
Server operators can configure the list of random drops in config.lua.
|
||||
|
||||
This is a fork of the [giftbox] mod.
|
||||
|
||||
Version: v3.0
|
||||
|
18
config.lua
18
config.lua
@ -1,9 +1,7 @@
|
||||
-- giftbox2 mod configuration file
|
||||
|
||||
local N = function(s) return s end
|
||||
-- Giftbox2 mod configuration file
|
||||
|
||||
-- Random gift box drops (format is same as for drop in the node definition)
|
||||
giftbox_drops = {
|
||||
giftbox2.config.drops = {
|
||||
-- digging gift box allows for a single drop of items with a given a rarity
|
||||
{ items = { "default:shovel_diamond" }, rarity = 300 },
|
||||
{ items = { "default:axe_mese" }, rarity = 290 },
|
||||
@ -48,9 +46,13 @@ giftbox_drops = {
|
||||
{ items = { "default:coal_lump" }, rarity = 0 },
|
||||
}
|
||||
|
||||
-------------------------------------------------------
|
||||
|
||||
local N = function(s) return s end
|
||||
|
||||
-- Gift box texts
|
||||
-- Warning: Changing these texts will break translation!
|
||||
giftbox_public_infotext1 = N("Gift Box")
|
||||
giftbox_public_infotext2 = N("“@1”")
|
||||
giftbox_private_infotext1 = N("Gift Box for @1")
|
||||
giftbox_private_infotext2 = N("Dear @1: “@2”")
|
||||
giftbox2.config.public_infotext1 = N("Gift Box")
|
||||
giftbox2.config.public_infotext2 = N("“@1”")
|
||||
giftbox2.config.private_infotext1 = N("Gift Box for @1")
|
||||
giftbox2.config.private_infotext2 = N("Dear @1: “@2”")
|
||||
|
21
init.lua
21
init.lua
@ -20,10 +20,14 @@ local is_owner = function( pos, player_name )
|
||||
end
|
||||
local STATUS_SIGNATURE_SET = "[giftbox2] %s sets message '%s' to %s at %s"
|
||||
|
||||
local config = minetest.load_config( )
|
||||
-- Load configutation
|
||||
giftbox2 = {}
|
||||
giftbox2.config = {}
|
||||
dofile(minetest.get_modpath("giftbox2") .. "/config.lua")
|
||||
local config = giftbox2.config
|
||||
|
||||
local box_colors = {
|
||||
-- color, decription, alias
|
||||
-- color, decription, uses alias
|
||||
{ "black", S("Black Gift Box"), true},
|
||||
{ "blue", S("Blue Gift Box"), true},
|
||||
{ "cyan", S("Cyan Gift Box"), true},
|
||||
@ -71,7 +75,7 @@ for i, colortab in ipairs( box_colors ) do
|
||||
}
|
||||
},
|
||||
|
||||
drop = { max_items = 1, items = config.giftbox_drops },
|
||||
drop = { max_items = 1, items = config.drops },
|
||||
|
||||
on_dig = function ( pos, node, player )
|
||||
local digger = player:get_player_name( )
|
||||
@ -102,7 +106,7 @@ for i, colortab in ipairs( box_colors ) do
|
||||
meta:set_string( "is_anonymous", "false" )
|
||||
|
||||
-- initial item string: Gift Box (from <placer>)
|
||||
meta:set_string( "infotext", S("@1 (from @2)", S(config.giftbox_public_infotext1), placer))
|
||||
meta:set_string( "infotext", S("@1 (from @2)", S(config.public_infotext1), placer))
|
||||
end,
|
||||
on_open = function ( pos, player, fields )
|
||||
local meta = minetest.get_meta( pos )
|
||||
@ -156,16 +160,16 @@ for i, colortab in ipairs( box_colors ) do
|
||||
if fields.receiver == OWNER_NOBODY then
|
||||
-- public gift box
|
||||
if fields.message == "" then
|
||||
infotext = S(config.giftbox_public_infotext1)
|
||||
infotext = S(config.public_infotext1)
|
||||
else
|
||||
infotext = S(config.giftbox_public_infotext2, fields.message)
|
||||
infotext = S(config.public_infotext2, fields.message)
|
||||
end
|
||||
else
|
||||
-- private gift box
|
||||
if fields.message == "" then
|
||||
infotext = S(config.giftbox_private_infotext1, fields.receiver)
|
||||
infotext = S(config.private_infotext1, fields.receiver)
|
||||
else
|
||||
infotext = S(config.giftbox_private_infotext2, fields.receiver, fields.message)
|
||||
infotext = S(config.private_infotext2, fields.receiver, fields.message)
|
||||
end
|
||||
end
|
||||
|
||||
@ -192,6 +196,7 @@ for i, colortab in ipairs( box_colors ) do
|
||||
} )
|
||||
|
||||
if colortab[3] then
|
||||
-- Alias for original giftbox mod
|
||||
minetest.register_alias("giftbox:giftbox_"..color, "giftbox2:giftbox_"..color)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user