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
|
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.
|
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.
|
This is a fork of the [giftbox] mod.
|
||||||
|
|
||||||
Version: v3.0
|
Version: v3.0
|
||||||
|
18
config.lua
18
config.lua
@ -1,9 +1,7 @@
|
|||||||
-- giftbox2 mod configuration file
|
-- Giftbox2 mod configuration file
|
||||||
|
|
||||||
local N = function(s) return s end
|
|
||||||
|
|
||||||
-- Random gift box drops (format is same as for drop in the node definition)
|
-- 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
|
-- digging gift box allows for a single drop of items with a given a rarity
|
||||||
{ items = { "default:shovel_diamond" }, rarity = 300 },
|
{ items = { "default:shovel_diamond" }, rarity = 300 },
|
||||||
{ items = { "default:axe_mese" }, rarity = 290 },
|
{ items = { "default:axe_mese" }, rarity = 290 },
|
||||||
@ -48,9 +46,13 @@ giftbox_drops = {
|
|||||||
{ items = { "default:coal_lump" }, rarity = 0 },
|
{ items = { "default:coal_lump" }, rarity = 0 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-------------------------------------------------------
|
||||||
|
|
||||||
|
local N = function(s) return s end
|
||||||
|
|
||||||
-- Gift box texts
|
-- Gift box texts
|
||||||
-- Warning: Changing these texts will break translation!
|
-- Warning: Changing these texts will break translation!
|
||||||
giftbox_public_infotext1 = N("Gift Box")
|
giftbox2.config.public_infotext1 = N("Gift Box")
|
||||||
giftbox_public_infotext2 = N("“@1”")
|
giftbox2.config.public_infotext2 = N("“@1”")
|
||||||
giftbox_private_infotext1 = N("Gift Box for @1")
|
giftbox2.config.private_infotext1 = N("Gift Box for @1")
|
||||||
giftbox_private_infotext2 = N("Dear @1: “@2”")
|
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
|
end
|
||||||
local STATUS_SIGNATURE_SET = "[giftbox2] %s sets message '%s' to %s at %s"
|
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 = {
|
local box_colors = {
|
||||||
-- color, decription, alias
|
-- color, decription, uses alias
|
||||||
{ "black", S("Black Gift Box"), true},
|
{ "black", S("Black Gift Box"), true},
|
||||||
{ "blue", S("Blue Gift Box"), true},
|
{ "blue", S("Blue Gift Box"), true},
|
||||||
{ "cyan", S("Cyan 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 )
|
on_dig = function ( pos, node, player )
|
||||||
local digger = player:get_player_name( )
|
local digger = player:get_player_name( )
|
||||||
@ -102,7 +106,7 @@ for i, colortab in ipairs( box_colors ) do
|
|||||||
meta:set_string( "is_anonymous", "false" )
|
meta:set_string( "is_anonymous", "false" )
|
||||||
|
|
||||||
-- initial item string: Gift Box (from <placer>)
|
-- 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,
|
end,
|
||||||
on_open = function ( pos, player, fields )
|
on_open = function ( pos, player, fields )
|
||||||
local meta = minetest.get_meta( pos )
|
local meta = minetest.get_meta( pos )
|
||||||
@ -156,16 +160,16 @@ for i, colortab in ipairs( box_colors ) do
|
|||||||
if fields.receiver == OWNER_NOBODY then
|
if fields.receiver == OWNER_NOBODY then
|
||||||
-- public gift box
|
-- public gift box
|
||||||
if fields.message == "" then
|
if fields.message == "" then
|
||||||
infotext = S(config.giftbox_public_infotext1)
|
infotext = S(config.public_infotext1)
|
||||||
else
|
else
|
||||||
infotext = S(config.giftbox_public_infotext2, fields.message)
|
infotext = S(config.public_infotext2, fields.message)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- private gift box
|
-- private gift box
|
||||||
if fields.message == "" then
|
if fields.message == "" then
|
||||||
infotext = S(config.giftbox_private_infotext1, fields.receiver)
|
infotext = S(config.private_infotext1, fields.receiver)
|
||||||
else
|
else
|
||||||
infotext = S(config.giftbox_private_infotext2, fields.receiver, fields.message)
|
infotext = S(config.private_infotext2, fields.receiver, fields.message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -192,6 +196,7 @@ for i, colortab in ipairs( box_colors ) do
|
|||||||
} )
|
} )
|
||||||
|
|
||||||
if colortab[3] then
|
if colortab[3] then
|
||||||
|
-- Alias for original giftbox mod
|
||||||
minetest.register_alias("giftbox:giftbox_"..color, "giftbox2:giftbox_"..color)
|
minetest.register_alias("giftbox:giftbox_"..color, "giftbox2:giftbox_"..color)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,4 +1,4 @@
|
|||||||
name = giftbox2
|
name = giftbox2
|
||||||
description = Gift boxes that players can give to other who will then receive random items
|
description = Gift boxes that players can give to other who will then receive random items
|
||||||
depends = config, formspecs
|
depends = formspecs
|
||||||
optional_depends = default
|
optional_depends = default
|
||||||
|
Loading…
x
Reference in New Issue
Block a user