Mod
Shop Dialog
Formspec-based shop dialog
Inspired by Genshin Impact, this mod provides a graphical menu suitable for NPC or admin-configured shops. This mod uses the flow Formspec library to handle visual layout, and the unified_money library to handle currency transactions.
API
shop_dialog.register_dialog(name,ShopDialog)
Register a shop dialog.
name: The identifier of the dialog.ShopDialog: AShopDialogobject.
shop_dialog.show_to(name,dialog_id)
Show a dialog to a player.
name: The name of the player.dialog_id: The identifier of the dialog as registered inshop_dialog.register_dialog.
Objects
ShopDialogEntry
A single entry in a ShopDialog.
{
-- The item to be given
item = ItemStack(),
-- Money to buy the item.
-- This uses the Unified Money system.
cost = 10,
-- Function returning the maximum allowed number of items to be brought.
-- This cannot exceed 100, and if exceed, it will fallback to 100.
-- If 0, the second returned value can be a string explaining the reason.
-- Default to a dummy function that returns 100.
max_amount = function(name) end,
-- Callback after the item had been brought.
-- Optional. If nil, nothing is called.
after_buy = function(name,amount) end,
}
ShopDialog
A shop dialog.
{
-- The title to be shown on top of the shops
-- Can be either string or function.
title = "Dave Null's Shop",
title = function(name) return "" end,
-- The footnote to be shown under the shops
-- Can be either string or function.
footnote = "Hello World!",
footnote = function(name) return "" end,
-- Callback after one of the entries are brought
-- Called after the entry's own callback
-- Optional. If nil, nothing is called.
after_buy = function(name,ShopDialogEntry,amount) end,
entries = {
-- List of ShopDialogEntry
}
} Links
- Source: https://github.com/MT-Companion/shop_dialog
- Issues: https://github.com/MT-Companion/shop_dialog/issues
- Original ContentDB page: content.luanti.org/packages/Emojiminetest/shop_dialog/
License
LGPL-2.1-or-later
Development state
ACTIVELY_DEVELOPED
| Version | Date | Min engine | Size | Download |
|---|---|---|---|---|
| luacheck | 2023-10-08 08:30:33 | 780.3 KB | Download |