mirror of
https://codeberg.org/usrib/emeraldbank.git
synced 2024-12-22 22:22:25 +01:00
emeraldbank.broadcast() func optional notifications_wrapper mod
This commit is contained in:
parent
6a4f98a137
commit
1263a9fee3
@ -21,6 +21,24 @@
|
|||||||
|
|
||||||
local S = core.get_translator(core.get_current_modname())
|
local S = core.get_translator(core.get_current_modname())
|
||||||
|
|
||||||
|
function emeraldbank.broadcast(player, msg, color, timeout)
|
||||||
|
if not player:is_player() then return end
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if core.get_modpath("notifications_wrapper") then
|
||||||
|
notifications.queue({
|
||||||
|
playerName = name,
|
||||||
|
title = S("EmeraldBank Notification"),
|
||||||
|
text = msg,
|
||||||
|
--image = "mcl_core_emerald.png",
|
||||||
|
timeout = timeout or 5
|
||||||
|
})
|
||||||
|
elseif core.get_modpath("mcl_title") then
|
||||||
|
mcl_title.set(player, "actionbar", {text=msg, color=color or "green"})
|
||||||
|
else
|
||||||
|
core.chat_send_player(name, msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function emeraldbank.get_emeralds(name)
|
function emeraldbank.get_emeralds(name)
|
||||||
atm.read_account(name)
|
atm.read_account(name)
|
||||||
return atm.balance[name]
|
return atm.balance[name]
|
||||||
@ -46,12 +64,7 @@ function emeraldbank.set_emeralds(player, num)
|
|||||||
|
|
||||||
if num then
|
if num then
|
||||||
atm.balance[name] = math.floor(num)
|
atm.balance[name] = math.floor(num)
|
||||||
|
emeraldbank.broadcast(player, S("Emeralds in Bank: @1", atm.balance[name]), "yellow")
|
||||||
-- Update actionbar only if 'player' is a player object
|
|
||||||
if type(player) ~= "string" then
|
|
||||||
mcl_title.set(player, "actionbar", {text=S("Emeralds in Bank: @1", atm.balance[name]), color="yellow"})
|
|
||||||
end
|
|
||||||
|
|
||||||
atm.save_account(name)
|
atm.save_account(name)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -78,12 +91,7 @@ function emeraldbank.add_emeralds(player, num)
|
|||||||
|
|
||||||
if num then
|
if num then
|
||||||
atm.balance[name] = math.floor(atm.balance[name] + num)
|
atm.balance[name] = math.floor(atm.balance[name] + num)
|
||||||
|
emeraldbank.broadcast(player, S("Emeralds in Bank: @1", atm.balance[name]), "yellow")
|
||||||
-- Update actionbar only if 'player' is a player object
|
|
||||||
if type(player) ~= "string" then
|
|
||||||
mcl_title.set(player, "actionbar", {text=S("Emeralds in Bank: @1", atm.balance[name]), color="yellow"})
|
|
||||||
end
|
|
||||||
|
|
||||||
atm.save_account(name)
|
atm.save_account(name)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -50,7 +50,7 @@ function emeraldbank.income(dtime)
|
|||||||
local had_start_balance = meta:get_string("emeraldbank_had_start_balance")
|
local had_start_balance = meta:get_string("emeraldbank_had_start_balance")
|
||||||
|
|
||||||
if had_start_balance == "" or had_start_balance == nil then
|
if had_start_balance == "" or had_start_balance == nil then
|
||||||
mcl_title.set(player, "actionbar", {text=S("You have earned your starting balance for playtime: @1", atm.startbalance), color="green"})
|
emeraldbank.broadcast(player, S("You have earned your starting balance for playtime: @1", atm.startbalance), "green")
|
||||||
emeraldbank.add_emeralds(player, atm.startbalance)
|
emeraldbank.add_emeralds(player, atm.startbalance)
|
||||||
meta:set_string("emeraldbank_had_start_balance", "true")
|
meta:set_string("emeraldbank_had_start_balance", "true")
|
||||||
end
|
end
|
||||||
|
4
mod.conf
4
mod.conf
@ -1,5 +1,5 @@
|
|||||||
name = emeraldbank
|
name = emeraldbank
|
||||||
depends = mcl_core, mcl_sounds, mcl_inventory, mcl_formspec, mcl_title
|
depends = mcl_core, mcl_sounds, mcl_inventory, mcl_formspec
|
||||||
optional_depends = irc, yl_matterbridge, awards, mail, beerchat
|
optional_depends = irc, yl_matterbridge, awards, mail, beerchat, notifications_wrapper, mcl_title
|
||||||
description = Keep your Emeralds in a bank!.
|
description = Keep your Emeralds in a bank!.
|
||||||
supported_games = mineclonia
|
supported_games = mineclonia
|
||||||
|
Loading…
Reference in New Issue
Block a user