Coder Social home page Coder Social logo

mailbox's Introduction

mailbox

A mod that adds mailboxes, based on the "old" xdecor mailboxes.

Original description

Thanks to @SmallJoker AKA Krock for helping me with the minetest.swap_node part of the mod!

Global storage

There is a "global storage" option in mailboxes that shares items between multiple mailboxes. The inventories for these mailboxes are stored in mod storage and temporarily loaded into a player inventory list for online players.

Global storage API

  • mailbox.room_for_item(player_or_name, item): Checks if player_or_name's global mailbox inventory can fit item. This may return false for offline players without a global mailbox inventory.
  • mailbox.send_to_player(player_or_name, item): Sends item to player_or_name's global mailbox inventory. Returns an ItemStack containing whatever couldn't fit into the mailbox.
  • mailbox.get_mailbox_inv_list(name): Similar to player:get_inventory():get_list("mailbox"), however also works with offline players.
  • mailbox.set_mailbox_inv_list(name, list): Similar to player:get_inventory():set_list("mailbox", new_list), however also works with offline players and saves the inventory list correctly.

Note that setting a player's mailbox list directly (with inventory:set_list()) will not update the mod storage copy, and if the server crashes or is shut down before the player logs out, the changes will not be stored.

Other mods can use mailbox.get_mailbox_inv_list(name) and mailbox.set_mailbox_inv_list(name, list) to manipulate these inventories. These functions are similar to InvRef:get_list(), however do not take a list parameter, and set_mailbox_inv_list() accepts ItemStrings as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.