GiftBox Mod v2.2
giftbox (by sorcerykid)
I finally broke down and decided to release one of the mods from the just_test_tribute subgame. The Giftbox Mod has been in continuous use on the JT2 server for the past two years, so it should be stable and secure enough for a production environment. The concept for this mod was inspired by mt_seasons from maikerumine.
For the most part, this mod should be usable right out of the box (no pun intended). It has only two dependencies and is fully compatible with all versions of Minetest 0.4.15 and later. To enjoy the full capabilities, however, I would also recommend installing protector_redo from TenPlus1.
Repository:
https://bitbucket.org/sorcerykid/giftbox
Download Archive (.zip)
Download Archive (.tar.gz)
Dependencies:
(repo) (zip) Active Formspecs Mod by sorcerykid
(repo) (zip) Basic Ownership Mod by sorcerykid
Source Code License:
GNU Lesser General Public License v3 (LGPL-3.0)
Multimedia License:
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
For complete release notes and licensing terms, please refer to the included README.txt file.
Gift Box Tutorial
Gift boxes are craftable by any player with one mese crystal, one cotton, three paper, and four colored wool. There are 8 possible gift boxes including black, white, red, green, blue, cyan, magenta, and yellow.
A player is permitted to place a gift box like any normal node, thereby obeying protection (if any). Once placed, the gift box is only customizable by that same player or by an administrator with the protection_bypass privilege. This is true regardless of the whether the gift box is actually placed within a protected area or not.
By right-clicking on the gift box, a customization screen is opened that allows for a personalized greeting and a designated recipient, both of which are optional. If "Anyonmous Gift" is checked, then the sender's name is not disclosed.
The infotext will change depending on which values are supplied by the player. Here are samples of the default strings:
- With no recipient and a greeting:
"Thank you for a wonderful year!" (from sorcerykid)
With a recipient and a greeting:
Dear maikerumine: "Thank you for a wonderful year!" (from sorcerykid)
With only a recipient and Anonymous Gift checked
Gift Box for maikerumine
With no recipient and no greeting
Gift Box (from sorcerykid)
For example, here is a gift box for maikerumine, placed by sorcerykid in her own protected area. If maikerumine were to dig this gift box, he would get a random item drop with no protection violation. However, if sorcerykid digs the gift box, then it will be returned to her inventory as expected since she owns the gift box.
Note, that sorcerykid can also dig the gift box even if the protected area belongs to a different player, since she retains ownership. However, she obviously can't replace the gift box, since that would incur a protection violation.
Item drops for gift boxes are selected at random from the giftbox.giftbox_drops table in config.lua:
Code: Select all
giftbox.giftbox_drops = {
-- digging gift box allows for a single drop of items with a given a rarity
{ items = { "default:sword_diamond" }, rarity = 50 },
{ items = { "default:sword_bronze" }, rarity = 25 },
{ items = { "default:pick_diamond" }, rarity = 50 },
{ items = { "default:pick_bronze" }, rarity = 25 },
-- default drop must be placed last and have rarity of 0 to avoid empty drops
{ items = { "default:gold_lump 5", "default:coal_lump 10" }, rarity = 0 },
}
It is also possible to change the infotext strings, if required for your subgame. However, in most cases the provided values should suffice:
Code: Select all
giftbox.giftbox_public_infotext1 = "Gift Box"
giftbox.giftbox_public_infotext2 = "'%s'"
giftbox.giftbox_private_infotext1 = "Gift Box for %s"
giftbox.giftbox_private_infotext2 = "Dear %s: '%s'"
Present Tutorial
Presents are made available for administrators with the "give" and "protection_bypass" privileges. Therefore they have no associated crafting recipe. They offer limited customization in comparison to gift boxes, since they are intended for widespread distribution as part of a delivery route on a public server (think Santa Claus).
For sake of expediency, the administrator will typically login to the server and issue the following command:
/giveme giftbox:present 99
These presents can be placed anywhere, even in protected areas of other players. By right-clicking on the present, the administrator can select from any one of several preset items. At least one item must be selected, otherwise the present will be nonfunctional.
The ability of other players to open a present is contingent on protection. Therefore, to deliver a present to a specific player, it must be placed inside that player's protected area. If, however, a present is intended to be opened by anyone (except players with the "give" privilege, of course), then it should be placed in an unprotected area.
By opening a present, a visual greeting will appear with a single inventory slot containing the preset item. After the item is taken from the inventory, then the present will be deleted from the world automatically.
Configuration of item presets is possible by editing the respective itemstrings from the giftbox.present_items table in config.lua. The infotext and greeting image can also be configured here, if necessary.
Code: Select all
giftbox.present_infotext = "Christmas Present"
giftbox.present_greeting = "present_greeting.png"
giftbox.present_items = {
"default:torch 60",
"default:apple 40",
"farming:bread 20",
"mt_seasons:pumpkin_slice 10",
"default:junglesapling 5",
"default:pine_sapling 5",
"default:aspen_sapling 5",
"default:acacia_sapling 5",
"default:pick_diamond",
"default:sword_diamond",
"default:pick_bronze",
"default:sword_bronze",
"3d_armor:helmet_diamond",
"3d_armor:leggings_diamond",
"3d_armor:chestplate_diamond",
"3d_armor:boots_diamond",
"default:coalblock 20",
"tnt:tnt 15",
"default:obsidian 10",
"default:snowblock 5",
"mobs:cursed_stone",
"jt_mods:griefer_soul_block",
"default:meselamp_white 10",
"default:meselamp 10",
}