Page 1 of 1

[Mod] Treasure Chest [1.1] [treasurechest]

PostPosted: Tue Dec 08, 2015 17:30
by thefamilygrog66
Treasure Chest (treasurechest) Mod

by thefamilygrog66

Description:

Adds treasure chests that a server admin can place, and fill with whatever treasures they choose. After the admin adds treasure to the chest, each player who finds it will be able to remove the same items that were originally added by the admin.

Cheers to bark for the idea/concept.

Update January 9 2016: I've rewritten the code so that now the admin simply fills the chest after placing it (i.e. no punching required to save its contents). Then, each player who finds it can examine its contents as many times as they want, removing what they like. The chest creates an inventory for each player, so that it remembers what has been taken by whom.

Mod Dependencies: default

License:

Sourcecode: WTFPL
Model: CC0 1.0, Paul Wortmann
Texture: WTFPL

Download: https://github.com/thefamilygrog66/treasurechest/archive/master.zip

Browse code on github: https://github.com/thefamilygrog66/treasurechest

Screenshot:

Image

Re: Treasure Chest

PostPosted: Tue Dec 08, 2015 19:21
by kaadmy
Uh, what does this mod do?

Re: Treasure Chest

PostPosted: Tue Dec 08, 2015 20:03
by thefamilygrog66
kaadmy wrote:Uh, what does this mod do?


Description and code to come, but I've basically done what bark was asking for here:

bark wrote:I want to make/see created a mod that adds a "treasure-chest" that can only be emptied once per player.

When placed, the chest must be configured with which items it is to contain. Once configured, the chest can be opened and emptied by any player, but only once per player.

Can someone can point me in a direction as to how I can achieve this?

Re: Treasure Chest

PostPosted: Wed Dec 09, 2015 13:11
by kaeza
code pls

Re: Treasure Chest

PostPosted: Wed Dec 09, 2015 16:51
by thefamilygrog66
kaeza wrote:code pls


I've just added a link to it, Kaeza - check it out!

Re: [Mod] Treasure Chest [1.0] [treasurechest]

PostPosted: Wed Dec 09, 2015 17:12
by bark
Great work on this, familygrog! The mod works very well!

Re: [Mod] Treasure Chest [1.0] [treasurechest]

PostPosted: Wed Dec 09, 2015 17:17
by sofar
I'm wondering why you limit each person from only ever looking once, which I don't think is really needed. You could create a detached inventory for each player (attached to the node), put the items in those inventories, and repeatedly give each user his copy of the detached inventory. This would allow each user to look and come back later to pick up stuff they could not carry. If you prevent putting stuff into the chest, you don't have to worry about people abusing it as a free chest either.

This code wouldn't be too difficult either: create an owner "master" detached inventory, and copy that to each players' detached inventory on demand. (sorry, didn't look at your code yet)

Re: [Mod] Treasure Chest [1.0] [treasurechest]

PostPosted: Wed Dec 09, 2015 17:20
by thefamilygrog66
bark wrote:Great work on this, familygrog! The mod works very well!


Thanks, and thank you for the idea.

Re: [Mod] Treasure Chest [1.0] [treasurechest]

PostPosted: Wed Dec 09, 2015 17:26
by thefamilygrog66
sofar wrote:I'm wondering why you limit each person from only ever looking once, which I don't think is really needed. You could create a detached inventory for each player (attached to the node), put the items in those inventories, and repeatedly give each user his copy of the detached inventory. This would allow each user to look and come back later to pick up stuff they could not carry. If you prevent putting stuff into the chest, you don't have to worry about people abusing it as a free chest either.

This code wouldn't be too difficult either: create an owner "master" detached inventory, and copy that to each players' detached inventory on demand. (sorry, didn't look at your code yet)


I wrote it that way because that's what bark had requested, and I was able to simply use the inventory array within the node's metadata (hint: I just doubled its capacity, but restricted the formspec to the first half). Your idea also makes sense, and I might look at making another version that behaves that way.

Re: [Mod] Treasure Chest [1.0] [treasurechest]

PostPosted: Wed Dec 09, 2015 18:18
by sofar
thefamilygrog66 wrote:I wrote it that way because that's what bark had requested, and I was able to simply use the inventory array within the node's metadata (hint: I just doubled its capacity, but restricted the formspec to the first half). Your idea also makes sense, and I might look at making another version that behaves that way.


Sure - what I'd do is make a minetest setting to determine the size and whether the inventory is one-time access only, leaving the option to the Server admin. That way people could make treasure chests with a single itemstack if they wish.

Additionally, perhaps people would like this idea as well: Restrict the *number* of items a player can withdraw, so that treasure chests become interesting collectible items: e.g. once players find a first chest with 4 items, but they're only allowed to take 1, perhaps they're more likely to go find the 3 other chests to complete a set.

Don't make twenty five versions of the same mod if you can avoid it, though. It helps to keep more people interested in the same code, you'll get better mods that way.

Re: [Mod] Treasure Chest [1.0] [treasurechest]

PostPosted: Sat Jan 09, 2016 18:37
by thefamilygrog66
sofar wrote:I'm wondering why you limit each person from only ever looking once, which I don't think is really needed. You could create a detached inventory for each player (attached to the node), put the items in those inventories, and repeatedly give each user his copy of the detached inventory. This would allow each user to look and come back later to pick up stuff they could not carry. If you prevent putting stuff into the chest, you don't have to worry about people abusing it as a free chest either.

This code wouldn't be too difficult either: create an owner "master" detached inventory, and copy that to each players' detached inventory on demand. (sorry, didn't look at your code yet)


Since this is the behaviour that Bark had originally requested anyway -- I misunderstood exactly what was requested -- I've rewritten the code so that now the admin simply fills the chest after placing it (i.e. no punching required to save its contents). Then, each player who finds it can examine its contents as many times as they want, removing what they like. The chest creates an inventory for each player, so that it remembers what has been taken by whom.

Re: [Mod] Treasure Chest [1.1] [treasurechest]

PostPosted: Tue May 17, 2016 03:17
by rpgsniper2452
Now I can hide my diamonds and mese better! lol
good mod too!

Re: [Mod] Treasure Chest [1.1] [treasurechest]

PostPosted: Sun Aug 21, 2016 00:29
by Sokomine
This mod is used on barks Barkhouse server. It works very well there. Treasure chests are hidden throughout the world and motivate players to explore, to climb, jump and otherwise reach all these positions where chests are stored.

The only problem is that there's no way to check for each player how many of the chests he/she has found already. It would be great to at least know how many (compared to those installed in total) each player has found. Assigning numbers or even descriptions to the chests might also be helpful in order to identify what has been missed. A global statistic could be entertaining :-)

Right now the mod is not aware of which chest sits where and which chests exist. Such information could be gathered whenever a chest is accessed and it's not yet known.

Could you include such a feature? :-)

Re: [Mod] Treasure Chest [1.1] [treasurechest]

PostPosted: Fri Aug 26, 2016 19:42
by thefamilygrog66
Hey, that's a cool idea Sokomine. I'll see what I can do...

Re: [Mod] Treasure Chest [1.1] [treasurechest]

PostPosted: Tue Oct 04, 2016 19:26
by ParaklataChotou
Thank you for this mod. I'll try on my server.

Re: [Mod] Treasure Chest [1.1] [treasurechest]

PostPosted: Wed Feb 14, 2018 23:00
by scottwolff
First mod that got offered to me by one of my moderators to use. Used it, liked it very much. Still use it currently. Good for one shots. Doesn't please everyone but everyone is sometimes lazy and don't want to go break a node here or there and make the items in the treasurechest theirselves XD