[Mod] Giftbox [giftbox]

User avatar
sorcerykid
Member
 
Posts: 902
Joined: Fri Aug 26, 2016 15:36
Location: Illinois, USA
GitHub: sorcerykid
In-game: Nemo

[Mod] Giftbox [giftbox]

by sorcerykid » Sun Dec 24, 2017 18:24

Image

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
Image

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.

Image

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.

Image

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)
If a recipient is specified, then the gift box is private, and only the player with that name may dig it for a random item. However, if a recipient is not specified, then the gift box is public and any player may dig the gift box for a random item drop. In this way it is also possible to share gifts, whether or not the gift box is placed inside a protected area.

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.

Image

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 },
}


Each gift box can only drop one set of items, so it is important to set "items" and "rarity" accordingly. The order is not important, except the default drop must be placed last and must have a rarity of 0 to ensure that it is selected whenever the preceding random drops fail.

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'"

Be certain to retain all of the %s tokens so that the appropriate values can be inserted into the string whenever the infotext is updated.

Present Tutorial
Image

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.

Image

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.

Image

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",
}


The dimensions for the greeting image should be at least 480 x 240 pixels (with an aspect ratio of 2:1). The graphic used in the screenshot was obtained from DreamsTime, a royalty-free stock image service. However, the individual license terms do not permit distribution. Therefore, you will need to supply your own graphic.
Last edited by sorcerykid on Tue Dec 25, 2018 18:26, edited 3 times in total.
 

User avatar
GamingAssociation39
Member
 
Posts: 758
Joined: Mon Apr 25, 2016 16:09
Location: Maryland, USA
GitHub: Gerold55
IRC: Gerold55
In-game: Gerold55

Re: [Mod] Giftbox [giftbox]

by GamingAssociation39 » Sun Dec 24, 2017 18:42

Can you help me get the same functionality for the Merry-Hollies Subgame?
Jesus Is Lord and Savior!!!
 

User avatar
sorcerykid
Member
 
Posts: 902
Joined: Fri Aug 26, 2016 15:36
Location: Illinois, USA
GitHub: sorcerykid
In-game: Nemo

Re: [Mod] Giftbox [giftbox]

by sorcerykid » Tue Jan 23, 2018 21:23

Version 2.1 Released

Another version of GiftBox is ready for download Here is the changelog:

  • escaped giftbox message in formspec string
  • improved validation of giftbox message input
This was primarily a bug fix release. It was committed a few weeks ago, but due to the holidays I forgot to publish the changes. Sorry!

 

User avatar
SaKeL
Member
 
Posts: 651
Joined: Tue Apr 14, 2015 18:39
GitHub: JurajVajda
IRC: SaKeL
In-game: SaKeL

Re: [Mod] Giftbox [giftbox]

by SaKeL » Wed Jan 24, 2018 05:03

omg i still recognize your old home on JT2 can't believe it's still there :) all the best wishes, nice mod !
 

User avatar
sorcerykid
Member
 
Posts: 902
Joined: Fri Aug 26, 2016 15:36
Location: Illinois, USA
GitHub: sorcerykid
In-game: Nemo

Re: [Mod] Giftbox [giftbox]

by sorcerykid » Mon Jan 29, 2018 22:50

GamingAssociation39 wrote:Can you help me get the same functionality for the Merry-Hollies Subgame?


Unfortunately, I don't have much time to contribute to side-projects, since I'm pre-occupied with family lately. But I do plan to continue development of this mod. You're more than welcome to incorporate it into your subgame (as long as you adhere to the license terms, of course). If you have any questions, just ask :)

SaKeL wrote:omg i still recognize your old home on JT2 can't believe it's still there :) all the best wishes, nice mod !


Awww, you're way too kind! Thanks for the compliment. Yep, the cottage has been officially designated a historic landmark :D
 

User avatar
sorcerykid
Member
 
Posts: 902
Joined: Fri Aug 26, 2016 15:36
Location: Illinois, USA
GitHub: sorcerykid
In-game: Nemo

Re: [Mod] Giftbox [giftbox]

by sorcerykid » Sun Aug 12, 2018 17:06

Quick update! Since I've been having problems with the BitBucket service lately, I've mirrored this repo to Notabug and MeseHub. Eventually I plan to migrate to one of these two hosts. I just haven't decided which one yet

The latest release can also be downloaded from the official ContentDB:

https://content.minetest.net/packages/s ... d/giftbox/

I believe that Notabug syncs git repos automatically, so the latest commits should appear there besides Bitbucket. I'll be sure to add these links to the first post as well. Thanks for your understanding!
 

User avatar
sorcerykid
Member
 
Posts: 902
Joined: Fri Aug 26, 2016 15:36
Location: Illinois, USA
GitHub: sorcerykid
In-game: Nemo

Re: [Mod] Giftbox [giftbox]

by sorcerykid » Tue Dec 25, 2018 17:30

Version 2.2 Released

With another yuletide celebration comes a new version of the GiftBox mod! This one is literally packed with exciting features. That's right, I've added packages. Now you can store your most valuable items inside a cardboard box and deliver them securely to another player. Here is the latest changelog:

  • added dependency for formspecs and ownership mods
  • introduced packages with specialized behavior
  • created textures for newly registered items
  • fixed regex during validation of recipient names
  • fixed erroneous checks against unowned nodes
  • general code refactoring and reformatting
Crafting a package is quick and easy. Just arrange eight pieces of paper into a square inside the craft grid.

Image

Next, drop an item onto the ground that you want to store inside the box. Then click to use the package on the dropped item. The item will be automatically sealed inside the box. If you are the owner of the package (or you have the "give" privilege), then you can view the contents and customize the description of the package by clicking to use it at any time.

Image

The description (displayed as a tooltip in the inventory) is dependent on the value of the Recipient field and the state of the Anonymous Sender checkbox. Here are samples of the default strings:

    Recipient cleared:
    Parcel (from sorcerykid on 25-Dec-2018)

    Recipient provided:
    Parcel for maikerumine (from sorcerykid on 25-Dec-2018)

    Recipient provided and Anonymous Sender checked:
    Parcel for maikerumine

    Recipient cleared and Anonymous Sender checked:
    Parcel
If a recipient is provided, then the package can only be viewed and opened by the designated player. The following informational screen will be presented with an option to unseal the package and retrieve the item. By clicking the "Open Package" button, the contents will be placed into the recipient's inventory.

Image

As you can see, the functionality of packages is different compared gift boxes described above. Since packages are not nodes, they cannot be placed in the world. Instead they are shared by dropping them on the ground (near the intended recipient) or by placing them into the mailbox or a protected chest (owned by intended recipient).

I hope you enjoy this gift from me to all of you for the holiday season!

Here's wishing everyone a Merry Christmas!
 


Return to WIP Mods



Who is online

Users browsing this forum: Exabot [Bot] and 2 guests