mirror of
https://gitlab.com/rubenwardy/awards.git
synced 2025-06-28 14:16:12 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
c27d527cfc | |||
37082d1186 | |||
6dc91cf893 | |||
8702b6cdd8 | |||
baf79bf9bf | |||
4f5260da5f | |||
89d4a93f3b | |||
cae2c1ee3b | |||
54db6ce0c0 |
@ -185,15 +185,16 @@ end
|
||||
* `secret` - boolean if this award is secret (i.e. showed on awards list)
|
||||
* `sound` - `SimpleSoundSpec` table to play on unlock.
|
||||
`false` to disable unlock sound.
|
||||
* `icon` - the icon image, use default otherwise.
|
||||
* `background` - the background image, use default otherwise.
|
||||
* `icon` - the icon image. Defaults to `awards_unknown.png`.
|
||||
* `hud_background` - the background image used in the HUD to contain the text and icon.
|
||||
Defaults to `awards_bg_default.png`.
|
||||
* `trigger` - trigger definition, see [Builtin Trigger Types](#builtin-trigger-types).
|
||||
* `on_unlock(name, def)` - callback on unlock.
|
||||
* `awards.registered_awards` - table of award name to definition.
|
||||
* `awards.register_on_unlock(func(name, def))`
|
||||
* `name` is the player name
|
||||
* `def` is the award def.
|
||||
* return true to cancel HUD
|
||||
* return true to cancel HUD from appearing.
|
||||
* `awards.unlock(player_name, award_name)`
|
||||
* gives an award to a player
|
||||
* `awards.get_award_states(player_name)`
|
||||
|
@ -95,7 +95,7 @@ function awards.unlock(name, award)
|
||||
-- Get Notification Settings
|
||||
local title = awdef.title or award
|
||||
local desc = awdef.description or ""
|
||||
local background = awdef.background or "awards_bg_default.png"
|
||||
local background = awdef.hud_background or awdef.background or "awards_bg_default.png"
|
||||
local icon = (awdef.icon or "awards_unknown.png") .. "^[resize:32x32"
|
||||
local sound = awdef.sound
|
||||
if sound == nil then
|
||||
@ -127,6 +127,9 @@ function awards.unlock(name, award)
|
||||
end
|
||||
else
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not (player and player.is_player and player:is_player()) then
|
||||
return
|
||||
end
|
||||
local one = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
name = "award_bg",
|
||||
|
@ -251,7 +251,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("Lava and Water"),
|
||||
description = S("Mine your first obsidian."),
|
||||
icon = "awards_lava_and_water.png^awards_level1.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 1.5,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -265,7 +265,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("Obsessed with Obsidian"),
|
||||
description = S("Mine 50 obsidian."),
|
||||
icon = "awards_obsessed_with_obsidian.png^awards_level2.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 1.5,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -279,7 +279,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("Lava Miner"),
|
||||
description = S("Mine any block while being very close to lava."),
|
||||
icon = "awards_lava_miner.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 1,
|
||||
})
|
||||
awards.register_on_dig(function(player,data)
|
||||
@ -386,7 +386,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("First Mese Find"),
|
||||
description = S("Mine your first mese ore."),
|
||||
icon = "awards_first_mese_find.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 1,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -401,7 +401,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("Mese Mastery"),
|
||||
description = S("Mine a mese block."),
|
||||
icon = "awards_mese_mastery.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 1.1,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -415,7 +415,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("You’re a copper"),
|
||||
description = S("Dig 1,000 copper ores."),
|
||||
icon = "awards_youre_a_copper.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 0.2,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -429,7 +429,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("Mini Miner"),
|
||||
description = S("Dig 100 stone blocks."),
|
||||
icon = "awards_mini_miner.png^awards_level1.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 0.02,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -443,7 +443,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("Hardened Miner"),
|
||||
description = S("Dig 1,000 stone blocks."),
|
||||
icon = "awards_hardened_miner.png^awards_level2.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 0.02,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -457,7 +457,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("Master Miner"),
|
||||
description = S("Dig 10,000 stone blocks."),
|
||||
icon = "awards_master_miner.png^awards_level3.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 0.02,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -471,7 +471,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("Marchand De Sable"),
|
||||
description = S("Dig 1,000 sand."),
|
||||
icon = "awards_marchand_de_sable.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 0.05,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -581,7 +581,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("First Gold Find"),
|
||||
description = S("Mine your first gold ore."),
|
||||
icon = "awards_first_gold_find.png^awards_level1.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 0.9,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -594,7 +594,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("Gold Rush"),
|
||||
description = S("Mine 45 gold ores."),
|
||||
icon = "awards_gold_rush.png^awards_level2.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 0.9,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
@ -619,7 +619,7 @@ if minetest.get_modpath("default") then
|
||||
title = S("Girl's Best Friend"),
|
||||
description = S("Mine 18 diamond ores."),
|
||||
icon = "awards_girls_best_friend.png^awards_level2.png",
|
||||
background = "awards_bg_mining.png",
|
||||
hud_background = "awards_bg_mining.png",
|
||||
difficulty = 1,
|
||||
trigger = {
|
||||
type = "dig",
|
||||
|
@ -2,28 +2,39 @@
|
||||
|
||||
local S = awards.gettext
|
||||
|
||||
minetest.register_privilege("awards_admin", { description = "Can manage awards of given player" })
|
||||
|
||||
minetest.register_chatcommand("awards", {
|
||||
params = S("[c|clear|disable|enable]"),
|
||||
description = S("Show, clear, disable or enable your awards"),
|
||||
params = "[c|clear|disable|enable] [player_name]",
|
||||
description = "Show, clear, disable or enable player's awards",
|
||||
func = function(name, param)
|
||||
if param == "clear" then
|
||||
awards.clear_player(name)
|
||||
minetest.chat_send_player(name,
|
||||
if not minetest.check_player_privs(name, { awards_admin = true }) then
|
||||
return false, "You need awards_admin privilege!"
|
||||
end
|
||||
local action, playern = param:split(" ")[1], param:split(" ")[2] or name
|
||||
if action == "clear" then
|
||||
awards.clear_player(playern)
|
||||
minetest.chat_send_player(playern,
|
||||
S("All your awards and statistics have been cleared. You can now start again."))
|
||||
elseif param == "disable" then
|
||||
awards.disable(name)
|
||||
minetest.chat_send_player(name, S("You have disabled awards."))
|
||||
elseif param == "enable" then
|
||||
awards.enable(name)
|
||||
minetest.chat_send_player(name, S("You have enabled awards."))
|
||||
elseif param == "c" then
|
||||
awards.show_to(name, name, nil, true)
|
||||
else
|
||||
minetest.chat_send_player(name, "All awards and statistics of "..playern.." have been cleared.")
|
||||
elseif action == "disable" then
|
||||
awards.disable(playern)
|
||||
minetest.chat_send_player(playern, "Your awards are disabled.")
|
||||
minetest.chat_send_player(name, "You have disabled awards of "..playern..".")
|
||||
elseif action == "enable" then
|
||||
awards.enable(playern)
|
||||
minetest.chat_send_player(playern, "Your awards are enabled.")
|
||||
minetest.chat_send_player(name, "You have enabled awards of "..playern..".")
|
||||
elseif action == "c" then
|
||||
awards.show_to(playern, name, nil, true)
|
||||
elseif not action then
|
||||
awards.show_to(name, name, nil, false)
|
||||
else
|
||||
awards.show_to(action, name, nil, true)
|
||||
end
|
||||
|
||||
if (param == "disable" or param == "enable") and minetest.global_exists("sfinv") then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if (action == "disable" or action == "enable") and minetest.global_exists("sfinv") and not minetest.get_modpath("unified_inventory") then
|
||||
local player = minetest.get_player_by_name(playern)
|
||||
if player then
|
||||
sfinv.set_player_inventory_formspec(player)
|
||||
end
|
||||
|
@ -80,7 +80,8 @@ function awards.load()
|
||||
os.rename(old_save_path, minetest.get_worldpath().."/awards.bk.txt")
|
||||
awards.save()
|
||||
else
|
||||
__player_data = minetest.parse_json(storage:get_string("player_data")) or {}
|
||||
local json = storage:get("player_data")
|
||||
__player_data = json and minetest.parse_json(json) or {}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -101,7 +101,7 @@ function awards.show_to(name, to, sid, text)
|
||||
if name == "" or name == nil then
|
||||
name = to
|
||||
end
|
||||
local data = awards.player(to)
|
||||
local data = awards.player(name)
|
||||
if name == to and data.disabled then
|
||||
minetest.chat_send_player(name, S("You've disabled awards. Type /awards enable to reenable."))
|
||||
return
|
||||
|
@ -113,15 +113,15 @@ awards.register_trigger("craft", {
|
||||
end,
|
||||
key_is_item = true,
|
||||
})
|
||||
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
|
||||
if not player_ok(player) or itemstack:is_empty() then
|
||||
return
|
||||
end
|
||||
|
||||
local itemname = itemstack:get_name()
|
||||
itemname = minetest.registered_aliases[itemname] or itemname
|
||||
awards.notify_craft(player, itemname, itemstack:get_count())
|
||||
end)
|
||||
--minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
|
||||
-- if not player_ok(player) or itemstack:is_empty() then
|
||||
-- return
|
||||
-- end
|
||||
--
|
||||
-- local itemname = itemstack:get_name()
|
||||
-- itemname = minetest.registered_aliases[itemname] or itemname
|
||||
-- awards.notify_craft(player, itemname, itemstack:get_count())
|
||||
--end)
|
||||
|
||||
|
||||
awards.register_trigger("eat", {
|
||||
|
Reference in New Issue
Block a user