[Mod] Giftbox [giftbox]

User avatar
sorcerykid
Member
 
Posts: 837
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.1
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 year, so it should be stable and secure enough for a production environment. The concept for this mod was inspired by mt_seasons from maikerumine.

There are only two principal dependences, both of which are part of the same subgame and therefore not "officially" released. But I am including them for sake of ensuring that this mod is usable. To enjoy the full capabilities, however, I would also recommend downloading and installing protector_redo from TenPlus1.

For the most part, this mod should be usable right out of the box (no pun intended). It has been tested extensively in Minetest 0.4.15 with the default subgame. However, you will want to skim through the configuration settings (described below) to ensure that all of the items are supported by your subgame.

Repository:

https://bitbucket.org/sorcerykid/giftbox
Download Archive (.zip)
Download Archive (.tar.gz)

Dependencies:

(repo) (zip) Active Formspecs Mod v2.0+ by sorcerykid
(repo) (zip) Basic Ownership Mod v2.0 by sorcerykid

Source Code License:

GNU Lesser General Public License v3 (LGPL-3.0)

Media License:

Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)

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 Jan 23, 2018 20:59, edited 2 times in total.
 

User avatar
GamingAssociation39
Member
 
Posts: 735
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: 837
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: 504
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 !
Follow my Collection for more Minetest creations found on my server or join the Community for the latest Server updates and news.

SaKeL
 

User avatar
sorcerykid
Member
 
Posts: 837
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: 837
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!
 


Return to WIP Mods



Who is online

Users browsing this forum: Majestic-12 [Bot] and 9 guests