Build 09
- migrated mod settings to configuration panel API
This commit is contained in:
parent
5ad8d58ea9
commit
87a6587971
|
@ -1,4 +1,4 @@
|
||||||
Giftbox Mod v2.3
|
Giftbox Mod v2.4
|
||||||
By Leslie E. Krause
|
By Leslie E. Krause
|
||||||
|
|
||||||
Giftbox provides an assortment user-customizable presents for special occasions, such as
|
Giftbox provides an assortment user-customizable presents for special occasions, such as
|
||||||
|
@ -73,6 +73,9 @@ Version 2.2 (Build 07)
|
||||||
Version 2.3 (Build 08)
|
Version 2.3 (Build 08)
|
||||||
- switched all ownership checks to use player names
|
- switched all ownership checks to use player names
|
||||||
|
|
||||||
|
Version 2.4 (Build 09)
|
||||||
|
- migrated mod settings to configuration panel API
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
47
config.lua
47
config.lua
|
@ -1,10 +1,9 @@
|
||||||
-- giftbox mod configuration file
|
-- giftbox mod configuration file
|
||||||
|
|
||||||
giftbox.present_infotext = "Christmas Present"
|
present_infotext = "Christmas Present"
|
||||||
giftbox.present_greeting = "present_greeting.png"
|
present_greeting = "present_greeting.png"
|
||||||
giftbox.package_viewer = "package_viewer.png"
|
|
||||||
|
|
||||||
giftbox.present_items = {
|
present_items = {
|
||||||
"default:torch 60",
|
"default:torch 60",
|
||||||
"default:apple 40",
|
"default:apple 40",
|
||||||
"farming:bread 20",
|
"farming:bread 20",
|
||||||
|
@ -36,26 +35,36 @@ giftbox.present_items = {
|
||||||
"default:meselamp 10",
|
"default:meselamp 10",
|
||||||
}
|
}
|
||||||
|
|
||||||
giftbox.parcel_public_description = "Parcel"
|
parcel_public_description = "Parcel"
|
||||||
giftbox.parcel_private_description = "Parcel for %s"
|
parcel_private_description = "Parcel for %s"
|
||||||
|
|
||||||
giftbox.giftbox_public_infotext1 = "Gift Box"
|
giftbox_message_length_min = 5
|
||||||
giftbox.giftbox_public_infotext2 = "'%s'"
|
giftbox_message_length_max = 150
|
||||||
giftbox.giftbox_private_infotext1 = "Gift Box for %s"
|
giftbox_public_infotext1 = "Gift Box"
|
||||||
giftbox.giftbox_private_infotext2 = "Dear %s: '%s'"
|
giftbox_public_infotext2 = "'%s'"
|
||||||
|
giftbox_private_infotext1 = "Gift Box for %s"
|
||||||
|
giftbox_private_infotext2 = "Dear %s: '%s'"
|
||||||
|
|
||||||
giftbox.giftbox_drops = {
|
giftbox_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:sword_diamond" }, rarity = 50 },
|
{ items = { "default:diamondblock" }, rarity = 160 },
|
||||||
{ items = { "default:sword_bronze" }, rarity = 25 },
|
{ items = { "default:goldblock" }, rarity = 160 },
|
||||||
|
|
||||||
{ items = { "default:pick_diamond" }, rarity = 50 },
|
{ items = { "default:coalblock 10" }, rarity = 80 },
|
||||||
{ items = { "default:pick_bronze" }, rarity = 25 },
|
{ items = { "default:obsidian 5" }, rarity = 80 },
|
||||||
|
|
||||||
{ items = { "default:gold_lump 5" }, rarity = 10 },
|
{ items = { "default:sword_diamond" }, rarity = 40 },
|
||||||
{ items = { "default:coal_lump 10" }, rarity = 10 },
|
{ items = { "default:pick_diamond" }, rarity = 40 },
|
||||||
|
|
||||||
|
{ items = { "default:sword_bronze" }, rarity = 20 },
|
||||||
|
{ items = { "default:pick_bronze" }, rarity = 20 },
|
||||||
|
|
||||||
|
{ items = { "farming:gingerbread_cookie 10" }, rarity = 10 },
|
||||||
|
{ items = { "farming:candycane 5" }, rarity = 10 },
|
||||||
|
|
||||||
|
{ items = { "default:apple 30" }, rarity = 5 },
|
||||||
|
{ items = { "default:orange 15" }, rarity = 5 },
|
||||||
|
|
||||||
-- default drop must be placed last and have rarity of 0 to avoid empty drops
|
-- default drop must be placed last and have rarity of 0 to avoid empty drops
|
||||||
{ items = { "farming:gingerbread_cookie 5", "farming:candycane 10" }, rarity = 0 },
|
{ items = { "default:coal_lump" }, rarity = 0 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
default
|
default
|
||||||
formspecs
|
formspecs
|
||||||
ownership
|
ownership
|
||||||
|
config
|
||||||
|
|
32
init.lua
32
init.lua
|
@ -1,15 +1,15 @@
|
||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
-- Minetest :: Giftbox Mod v2.3 (giftbox)
|
-- Minetest :: Giftbox Mod v2.4 (giftbox)
|
||||||
--
|
--
|
||||||
-- See README.txt for licensing and other information.
|
-- See README.txt for licensing and other information.
|
||||||
-- Copyright (c) 2016-2018, Leslie E. Krause
|
-- Copyright (c) 2016-2020, Leslie E. Krause
|
||||||
--
|
--
|
||||||
-- ./games/minetest_game/mods/giftbox/init.lua
|
-- ./games/minetest_game/mods/giftbox/init.lua
|
||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
|
|
||||||
giftbox = { }
|
giftbox = { }
|
||||||
|
|
||||||
dofile( minetest.get_modpath( "giftbox" ) .. "/config.lua" )
|
local config = minetest.load_config( )
|
||||||
|
|
||||||
local box_colors = { "black", "blue", "cyan", "green", "magenta", "red", "white", "yellow" }
|
local box_colors = { "black", "blue", "cyan", "green", "magenta", "red", "white", "yellow" }
|
||||||
-- black = black + grey
|
-- black = black + grey
|
||||||
|
@ -39,7 +39,7 @@ minetest.register_node( "giftbox:present", {
|
||||||
drop = { },
|
drop = { },
|
||||||
|
|
||||||
after_place_node = function ( pos, player )
|
after_place_node = function ( pos, player )
|
||||||
minetest.get_meta( pos ):set_string( "infotext", giftbox.present_infotext .. " (placed by " .. player:get_player_name( ) .. ")" )
|
minetest.get_meta( pos ):set_string( "infotext", config.present_infotext .. " (placed by " .. player:get_player_name( ) .. ")" )
|
||||||
end,
|
end,
|
||||||
on_construct = function ( pos )
|
on_construct = function ( pos )
|
||||||
local meta = minetest.get_meta( pos )
|
local meta = minetest.get_meta( pos )
|
||||||
|
@ -83,7 +83,7 @@ minetest.register_node( "giftbox:present", {
|
||||||
"list[nodemeta:%s;main;6,0.5;1,1;]"
|
"list[nodemeta:%s;main;6,0.5;1,1;]"
|
||||||
|
|
||||||
slot = 0
|
slot = 0
|
||||||
for _, name in ipairs( giftbox.present_items ) do
|
for _, name in ipairs( config.present_items ) do
|
||||||
formspec = formspec .. "item_image_button[ " .. ( slot % 8 ) .. "," .. ( math.floor ( slot / 8 ) + 2 ) .. ";1,1;" .. name .. ";add " .. name .. ";]"
|
formspec = formspec .. "item_image_button[ " .. ( slot % 8 ) .. "," .. ( math.floor ( slot / 8 ) + 2 ) .. ";1,1;" .. name .. ";add " .. name .. ";]"
|
||||||
slot = slot + 1
|
slot = slot + 1
|
||||||
end
|
end
|
||||||
|
@ -94,7 +94,7 @@ minetest.register_node( "giftbox:present", {
|
||||||
|
|
||||||
local formspec =
|
local formspec =
|
||||||
"size[10,6.5]" ..
|
"size[10,6.5]" ..
|
||||||
"image[0,0;12,6;" .. giftbox.present_greeting .. "]" ..
|
"image[0,0;12,6;" .. config.present_greeting .. "]" ..
|
||||||
default.gui_bg ..
|
default.gui_bg ..
|
||||||
default.gui_bg_img ..
|
default.gui_bg_img ..
|
||||||
default.gui_slots ..
|
default.gui_slots ..
|
||||||
|
@ -145,7 +145,7 @@ minetest.register_craftitem( "giftbox:package_unsealed", {
|
||||||
local new_stack = ItemStack( "giftbox:package_sealed" )
|
local new_stack = ItemStack( "giftbox:package_sealed" )
|
||||||
local meta = new_stack:get_meta( )
|
local meta = new_stack:get_meta( )
|
||||||
|
|
||||||
meta:set_string( "description", giftbox.parcel_public_description ..
|
meta:set_string( "description", config.parcel_public_description ..
|
||||||
" (from " .. player_name .. " on " .. os.date( "%x" ) .. ")" )
|
" (from " .. player_name .. " on " .. os.date( "%x" ) .. ")" )
|
||||||
meta:set_string( "timestamp", os.time( ) )
|
meta:set_string( "timestamp", os.time( ) )
|
||||||
meta:set_string( "receiver", default.OWNER_NOBODY )
|
meta:set_string( "receiver", default.OWNER_NOBODY )
|
||||||
|
@ -213,8 +213,8 @@ minetest.register_craftitem( "giftbox:package_sealed", {
|
||||||
|
|
||||||
-- public vs. private letters and parcels
|
-- public vs. private letters and parcels
|
||||||
local description = fields.receiver == default.OWNER_NOBODY and
|
local description = fields.receiver == default.OWNER_NOBODY and
|
||||||
giftbox.parcel_public_description or
|
config.parcel_public_description or
|
||||||
string.format( giftbox.parcel_private_description, fields.receiver )
|
string.format( config.parcel_private_description, fields.receiver )
|
||||||
|
|
||||||
if meta:get_string( "is_anonymous" ) == "false" then
|
if meta:get_string( "is_anonymous" ) == "false" then
|
||||||
description = description .. " (from " .. owner .. " on " .. os.date( "%x", tonumber( meta:get_string( "timestamp" ) ) ) .. ")"
|
description = description .. " (from " .. owner .. " on " .. os.date( "%x", tonumber( meta:get_string( "timestamp" ) ) ) .. ")"
|
||||||
|
@ -232,7 +232,7 @@ minetest.register_craftitem( "giftbox:package_sealed", {
|
||||||
"size[9,7]" ..
|
"size[9,7]" ..
|
||||||
default.gui_bg ..
|
default.gui_bg ..
|
||||||
default.gui_bg_img ..
|
default.gui_bg_img ..
|
||||||
"background[0,0;9,6;" .. giftbox.package_viewer .. "]" ..
|
"background[0,0;9,6;" .. config.package_viewer .. "]" ..
|
||||||
"label[0.5,0.5;" .. minetest.colorize( "#000000", os.date( "%x %X", tonumber( meta:get_string( "timestamp" ) ) ) ) .. "]" ..
|
"label[0.5,0.5;" .. minetest.colorize( "#000000", os.date( "%x %X", tonumber( meta:get_string( "timestamp" ) ) ) ) .. "]" ..
|
||||||
"button_exit[3.0,6.5;3.0,0.3;open;Open Package]"
|
"button_exit[3.0,6.5;3.0,0.3;open;Open Package]"
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ for i, color in ipairs( box_colors ) do
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
drop = { max_items = 1, items = giftbox.giftbox_drops },
|
drop = { max_items = 1, items = config.giftbox_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( )
|
||||||
|
@ -319,7 +319,7 @@ for i, color in ipairs( box_colors ) do
|
||||||
meta:set_string( "is_anonymous", "false" )
|
meta:set_string( "is_anonymous", "false" )
|
||||||
|
|
||||||
-- initial item string: Gift Box (placed by sorcerykid)
|
-- initial item string: Gift Box (placed by sorcerykid)
|
||||||
meta:set_string( "infotext", giftbox.giftbox_public_infotext1 .. " (from " .. placer .. ")" )
|
meta:set_string( "infotext", config.giftbox_public_infotext1 .. " (from " .. 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 )
|
||||||
|
@ -374,13 +374,13 @@ for i, color in ipairs( box_colors ) do
|
||||||
if fields.receiver == default.OWNER_NOBODY then
|
if fields.receiver == default.OWNER_NOBODY then
|
||||||
-- public gift box
|
-- public gift box
|
||||||
infotext = fields.message == "" and
|
infotext = fields.message == "" and
|
||||||
giftbox.giftbox_public_infotext1 or
|
config.giftbox_public_infotext1 or
|
||||||
string.format( giftbox.giftbox_public_infotext2, fields.message )
|
string.format( config.giftbox_public_infotext2, fields.message )
|
||||||
else
|
else
|
||||||
-- private gift box
|
-- private gift box
|
||||||
infotext = fields.message == "" and
|
infotext = fields.message == "" and
|
||||||
string.format( giftbox.giftbox_private_infotext1, fields.receiver ) or
|
string.format( config.giftbox_private_infotext1, fields.receiver ) or
|
||||||
string.format( giftbox.giftbox_private_infotext2, fields.receiver, fields.message )
|
string.format( config.giftbox_private_infotext2, fields.receiver, fields.message )
|
||||||
end
|
end
|
||||||
|
|
||||||
if meta:get_string( "is_anonymous" ) == "false" then
|
if meta:get_string( "is_anonymous" ) == "false" then
|
||||||
|
|
Loading…
Reference in New Issue