mirror of
https://codeberg.org/usrib/emeraldbank.git
synced 2024-12-22 22:22:25 +01:00
inv tab
This commit is contained in:
parent
b6d47dc584
commit
658b34e295
1
init.lua
1
init.lua
@ -42,6 +42,7 @@ dofile(modpath .. "/receive_fields.lua") -- file adapted from atm mod
|
|||||||
dofile(modpath .. "/receive_fields_wt.lua") -- file from atm mod
|
dofile(modpath .. "/receive_fields_wt.lua") -- file from atm mod
|
||||||
dofile(modpath .. "/bank.lua")
|
dofile(modpath .. "/bank.lua")
|
||||||
dofile(modpath .. "/commands.lua")
|
dofile(modpath .. "/commands.lua")
|
||||||
|
dofile(modpath .. "/invtab.lua")
|
||||||
|
|
||||||
if income_enabled then
|
if income_enabled then
|
||||||
dofile(modpath .. "/income.lua")
|
dofile(modpath .. "/income.lua")
|
||||||
|
80
invtab.lua
Normal file
80
invtab.lua
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
|
||||||
|
|
||||||
|
-- Copyright (C) 2021, 2024 Sandro del Toro
|
||||||
|
|
||||||
|
-- This file is part of Emeraldbank Minetest Mod.
|
||||||
|
|
||||||
|
-- Emeraldbank is free software: you can redistribute it and/or modify
|
||||||
|
-- it under the terms of the GNU Affero General Public License as
|
||||||
|
-- published by the Free Software Foundation, either version 3 of the
|
||||||
|
-- License, or (at your option) any later version.
|
||||||
|
|
||||||
|
-- Emeraldbank is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
-- You should have received a copy of the GNU Affero General Public License
|
||||||
|
-- along with Emeraldbank. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local S = core.get_translator(core.get_current_modname())
|
||||||
|
local show_tab = core.settings:get_bool("emeraldbank.inv_tab", true)
|
||||||
|
|
||||||
|
-- This function must return the tab's formspec for the player
|
||||||
|
local function build(player)
|
||||||
|
local fs = "label[1,1;"..S("Open EmeraldBank interface").."]"..
|
||||||
|
"image_button[1,1.3;1,1;default_steel_block.png^mcl_core_emerald.png;bank;".."".."]"
|
||||||
|
if core.get_modpath("emeraldmarket") then
|
||||||
|
fs = fs.."label[1,3;"..S("Open Auction Market interface").."]"..
|
||||||
|
"image_button[1,3.3;1,1;default_gold_block.png^mcl_core_emerald.png;market;".."".."]"
|
||||||
|
end
|
||||||
|
return fs
|
||||||
|
end
|
||||||
|
|
||||||
|
-- This function will be called in the on_player_receive_fields callback if the tab is currently open
|
||||||
|
-- function(player, formname, fields)
|
||||||
|
local function handle(player, fields)
|
||||||
|
if fields.bank then
|
||||||
|
atm.showform(player)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
if core.get_modpath("emeraldmarket") and commoditymarket and fields.market then
|
||||||
|
local name = player:get_player_name()
|
||||||
|
commoditymarket.show_market("emerald", name)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- This function will be called to know if a player can see the tab
|
||||||
|
-- Returns true by default
|
||||||
|
local function access(player)
|
||||||
|
return show_tab
|
||||||
|
end
|
||||||
|
|
||||||
|
mcl_inventory.register_survival_inventory_tab({
|
||||||
|
-- Page identifier
|
||||||
|
-- Used to uniquely identify the tab
|
||||||
|
id = "emeraldbank",
|
||||||
|
|
||||||
|
-- The tab description, can be translated
|
||||||
|
description = S("Economy"),
|
||||||
|
|
||||||
|
-- The name of the item that will be used as icon
|
||||||
|
item_icon = "mcl_core:emerald",
|
||||||
|
|
||||||
|
-- If true, the main inventory will be shown at the bottom of the tab
|
||||||
|
-- Listrings need to be added by hand
|
||||||
|
show_inventory = true,
|
||||||
|
|
||||||
|
-- This function must return the tab's formspec for the player
|
||||||
|
build = build,
|
||||||
|
|
||||||
|
-- This function will be called in the on_player_receive_fields callback if the tab is currently open
|
||||||
|
handle = handle,
|
||||||
|
|
||||||
|
-- This function will be called to know if a player can see the tab
|
||||||
|
-- Returns true by default
|
||||||
|
access = access,
|
||||||
|
})
|
@ -18,3 +18,6 @@ emeraldbank.income_count (number of emeralds) int 1
|
|||||||
|
|
||||||
# Length of time (in seconds) between checking if a player should get income
|
# Length of time (in seconds) between checking if a player should get income
|
||||||
emeraldbank.income_period (time between income) int 1800
|
emeraldbank.income_period (time between income) int 1800
|
||||||
|
|
||||||
|
# Show inventory tab
|
||||||
|
emeraldbank.inv_tab (Show inventory tab) bool true
|
||||||
|
Loading…
Reference in New Issue
Block a user