Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
d38ba4e8a0 | |||
f5ea95ad35 | |||
9b6e93dd9a | |||
49f251136e | |||
9308b95163 | |||
f6515c12b8 | |||
00eeeb3eef | |||
5dec2fd60b | |||
7eeebf0f40 | |||
b689dc8eaf | |||
f5cf49af2e | |||
48bb2e9656 |
82
api.lua
@ -77,7 +77,7 @@ function awards.run_trigger_callbacks(player, data, trigger, table_func)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function awards.increment_item_counter(data, field, itemname)
|
function awards.increment_item_counter(data, field, itemname, count)
|
||||||
local name_split = string.split(itemname, ":")
|
local name_split = string.split(itemname, ":")
|
||||||
if #name_split ~= 2 then
|
if #name_split ~= 2 then
|
||||||
return false
|
return false
|
||||||
@ -91,13 +91,30 @@ function awards.increment_item_counter(data, field, itemname)
|
|||||||
awards.tbv(data[field], mod)
|
awards.tbv(data[field], mod)
|
||||||
awards.tbv(data[field][mod], item, 0)
|
awards.tbv(data[field][mod], item, 0)
|
||||||
|
|
||||||
data[field][mod][item] = data[field][mod][item] + 1
|
data[field][mod][item] = data[field][mod][item] + (count or 1)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function awards.get_item_count(data, field, itemname)
|
||||||
|
local name_split = string.split(itemname, ":")
|
||||||
|
if #name_split ~= 2 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local mod = name_split[1]
|
||||||
|
local item = name_split[2]
|
||||||
|
|
||||||
|
if data and field and mod and item then
|
||||||
|
awards.assertPlayer(data)
|
||||||
|
awards.tbv(data, field)
|
||||||
|
awards.tbv(data[field], mod)
|
||||||
|
awards.tbv(data[field][mod], item, 0)
|
||||||
|
return data[field][mod][item]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function awards.register_on_unlock(func)
|
function awards.register_on_unlock(func)
|
||||||
table.insert(awards.on_unlock, func)
|
table.insert(awards.on_unlock, func)
|
||||||
end
|
end
|
||||||
@ -203,9 +220,16 @@ function awards.unlock(name, award)
|
|||||||
-- Get Notification Settings
|
-- Get Notification Settings
|
||||||
local title = awdef.title or award
|
local title = awdef.title or award
|
||||||
local desc = awdef.description or ""
|
local desc = awdef.description or ""
|
||||||
local background = awdef.background or "bg_default.png"
|
local background = awdef.background or "awards_bg_default.png"
|
||||||
local icon = awdef.icon or "unknown.png"
|
local icon = awdef.icon or "awards_unknown.png"
|
||||||
local custom_announce = awdef.custom_announce or S("Achievement Unlocked:")
|
local custom_announce = awdef.custom_announce
|
||||||
|
if not custom_announce then
|
||||||
|
if awdef.secret then
|
||||||
|
custom_announce = S("Secret Achievement Unlocked:")
|
||||||
|
else
|
||||||
|
custom_announce = S("Achievement Unlocked:")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Do Notification
|
-- Do Notification
|
||||||
if awards.show_mode == "formspec" then
|
if awards.show_mode == "formspec" then
|
||||||
@ -216,8 +240,14 @@ function awards.unlock(name, award)
|
|||||||
"label[1.1,1;"..title.."]"..
|
"label[1.1,1;"..title.."]"..
|
||||||
"label[0.3,0.1;"..custom_announce.."]")
|
"label[0.3,0.1;"..custom_announce.."]")
|
||||||
elseif awards.show_mode == "chat" then
|
elseif awards.show_mode == "chat" then
|
||||||
|
local chat_announce
|
||||||
|
if awdef.secret == true then
|
||||||
|
chat_announce = S("Secret Achievement Unlocked: %s")
|
||||||
|
else
|
||||||
|
chat_announce = S("Achievement Unlocked: %s")
|
||||||
|
end
|
||||||
-- use the chat console to send it
|
-- use the chat console to send it
|
||||||
minetest.chat_send_player(name, S("Achievement Unlocked:")..title)
|
minetest.chat_send_player(name, string.format(chat_announce, title))
|
||||||
if desc~="" then
|
if desc~="" then
|
||||||
minetest.chat_send_player(name, desc)
|
minetest.chat_send_player(name, desc)
|
||||||
end
|
end
|
||||||
@ -232,12 +262,18 @@ function awards.unlock(name, award)
|
|||||||
offset = {x = 0, y = 138},
|
offset = {x = 0, y = 138},
|
||||||
alignment = {x = 0, y = -1}
|
alignment = {x = 0, y = -1}
|
||||||
})
|
})
|
||||||
|
local hud_announce
|
||||||
|
if awdef.secret == true then
|
||||||
|
hud_announce = S("Secret Achievement Unlocked!")
|
||||||
|
else
|
||||||
|
hud_announce = S("Achievement Unlocked!")
|
||||||
|
end
|
||||||
local two = player:hud_add({
|
local two = player:hud_add({
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
name = "award_au",
|
name = "award_au",
|
||||||
number = 0xFFFFFF,
|
number = 0xFFFFFF,
|
||||||
scale = {x = 100, y = 20},
|
scale = {x = 100, y = 20},
|
||||||
text = "Achievement Unlocked!",
|
text = hud_announce,
|
||||||
position = {x = 0.5, y = 0},
|
position = {x = 0.5, y = 0},
|
||||||
offset = {x = 0, y = 40},
|
offset = {x = 0, y = 40},
|
||||||
alignment = {x = 0, y = -1}
|
alignment = {x = 0, y = -1}
|
||||||
@ -282,18 +318,19 @@ awards.give_achievement = awards.unlock
|
|||||||
})]]--
|
})]]--
|
||||||
|
|
||||||
function awards.getFormspec(name, to, sid)
|
function awards.getFormspec(name, to, sid)
|
||||||
local formspec = "size[11,5]"
|
local formspec = ""
|
||||||
local listofawards = awards._order_awards(name)
|
local listofawards = awards._order_awards(name)
|
||||||
|
local playerdata = awards.players[name]
|
||||||
|
|
||||||
-- Sidebar
|
-- Sidebar
|
||||||
if sid then
|
if sid then
|
||||||
local item = listofawards[sid+0]
|
local item = listofawards[sid+0]
|
||||||
local def = awards.def[item.name]
|
local def = awards.def[item.name]
|
||||||
if def and def.secret and not item.got then
|
if def and def.secret and not item.got then
|
||||||
formspec = formspec .. "label[1,2.75;Secret Award]"..
|
formspec = formspec .. "label[1,2.75;(Secret Award)]"..
|
||||||
"image[1,0;3,3;unknown.png]"
|
"image[1,0;3,3;awards_unknown.png]"
|
||||||
if def and def.description then
|
if def and def.description then
|
||||||
formspec = formspec .. "label[0,3.25;Unlock this award to find out what it is]"
|
formspec = formspec .. "label[0,3.25;Unlock this award to find out what it is.]"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local title = item.name
|
local title = item.name
|
||||||
@ -308,6 +345,24 @@ function awards.getFormspec(name, to, sid)
|
|||||||
if def and def.icon then
|
if def and def.icon then
|
||||||
formspec = formspec .. "image[1,0;3,3;" .. def.icon .. "]"
|
formspec = formspec .. "image[1,0;3,3;" .. def.icon .. "]"
|
||||||
end
|
end
|
||||||
|
local barwidth = 4.6
|
||||||
|
local perc = nil
|
||||||
|
local label = nil
|
||||||
|
if def.getProgress and playerdata then
|
||||||
|
local res = def:getProgress(playerdata)
|
||||||
|
perc = res.perc
|
||||||
|
label = res.label
|
||||||
|
end
|
||||||
|
if perc then
|
||||||
|
if perc > 1 then
|
||||||
|
perc = 1
|
||||||
|
end
|
||||||
|
formspec = formspec .. "background[0,4.80;" .. barwidth ..",0.25;awards_progress_gray.png;false]"
|
||||||
|
formspec = formspec .. "background[0,4.80;" .. (barwidth * perc) ..",0.25;awards_progress_green.png;false]"
|
||||||
|
if label then
|
||||||
|
formspec = formspec .. "label[1.75,4.63;" .. label .. "]"
|
||||||
|
end
|
||||||
|
end
|
||||||
if def and def.description then
|
if def and def.description then
|
||||||
formspec = formspec .. "label[0,3.25;"..def.description.."]"
|
formspec = formspec .. "label[0,3.25;"..def.description.."]"
|
||||||
end
|
end
|
||||||
@ -326,7 +381,7 @@ function awards.getFormspec(name, to, sid)
|
|||||||
first = false
|
first = false
|
||||||
|
|
||||||
if def.secret and not award.got then
|
if def.secret and not award.got then
|
||||||
formspec = formspec .. "#ACACACSecret Award"
|
formspec = formspec .. "#707070(Secret Award)"
|
||||||
else
|
else
|
||||||
local title = award.name
|
local title = award.name
|
||||||
if def and def.title then
|
if def and def.title then
|
||||||
@ -378,7 +433,8 @@ function awards.show_to(name, to, sid, text)
|
|||||||
sid = 1
|
sid = 1
|
||||||
end
|
end
|
||||||
-- Show formspec to user
|
-- Show formspec to user
|
||||||
minetest.show_formspec(to,"awards:awards", awards.getFormspec(name, to, sid))
|
minetest.show_formspec(to,"awards:awards",
|
||||||
|
"size[11,5]" .. awards.getFormspec(name, to, sid))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
awards.showto = awards.show_to
|
awards.showto = awards.show_to
|
||||||
|
@ -1 +1,3 @@
|
|||||||
intllib?
|
intllib?
|
||||||
|
sfinv?
|
||||||
|
unified_inventory?
|
||||||
|
344
init.lua
@ -25,6 +25,8 @@ end
|
|||||||
|
|
||||||
dofile(minetest.get_modpath("awards").."/api.lua")
|
dofile(minetest.get_modpath("awards").."/api.lua")
|
||||||
dofile(minetest.get_modpath("awards").."/chat_commands.lua")
|
dofile(minetest.get_modpath("awards").."/chat_commands.lua")
|
||||||
|
dofile(minetest.get_modpath("awards").."/sfinv.lua")
|
||||||
|
dofile(minetest.get_modpath("awards").."/unified_inventory.lua")
|
||||||
dofile(minetest.get_modpath("awards").."/triggers.lua")
|
dofile(minetest.get_modpath("awards").."/triggers.lua")
|
||||||
awards.set_intllib(S)
|
awards.set_intllib(S)
|
||||||
|
|
||||||
@ -32,7 +34,7 @@ awards.set_intllib(S)
|
|||||||
awards.register_achievement("award_lightitup",{
|
awards.register_achievement("award_lightitup",{
|
||||||
title = S("Light It Up"),
|
title = S("Light It Up"),
|
||||||
description = S("Place 100 torches."),
|
description = S("Place 100 torches."),
|
||||||
icon = "novicebuilder.png",
|
icon = "awards_novicebuilder.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "place",
|
type = "place",
|
||||||
node = "default:torch",
|
node = "default:torch",
|
||||||
@ -44,7 +46,7 @@ awards.register_achievement("award_lightitup",{
|
|||||||
awards.register_achievement("award_well_lit",{
|
awards.register_achievement("award_well_lit",{
|
||||||
title = S("Well Lit"),
|
title = S("Well Lit"),
|
||||||
description = S("Place 1,000 torches."),
|
description = S("Place 1,000 torches."),
|
||||||
icon = "novicebuilder.png",
|
icon = "awards_novicebuilder.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "place",
|
type = "place",
|
||||||
node = "default:torch",
|
node = "default:torch",
|
||||||
@ -58,7 +60,7 @@ if minetest.get_modpath("moreblocks") then
|
|||||||
awards.register_achievement("award_saint_maclou",{
|
awards.register_achievement("award_saint_maclou",{
|
||||||
title = S("Saint-Maclou"),
|
title = S("Saint-Maclou"),
|
||||||
description = S("Place 20 coal checkers."),
|
description = S("Place 20 coal checkers."),
|
||||||
icon = "novicebuilder.png",
|
icon = "awards_novicebuilder.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "place",
|
type = "place",
|
||||||
node = "moreblocks:coal_checker",
|
node = "moreblocks:coal_checker",
|
||||||
@ -70,7 +72,7 @@ if minetest.get_modpath("moreblocks") then
|
|||||||
awards.register_achievement("award_castorama",{
|
awards.register_achievement("award_castorama",{
|
||||||
title = S("Castorama"),
|
title = S("Castorama"),
|
||||||
description = S("Place 20 iron checkers."),
|
description = S("Place 20 iron checkers."),
|
||||||
icon = "novicebuilder.png",
|
icon = "awards_novicebuilder.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "place",
|
type = "place",
|
||||||
node = "moreblocks:iron_checker",
|
node = "moreblocks:iron_checker",
|
||||||
@ -82,7 +84,7 @@ if minetest.get_modpath("moreblocks") then
|
|||||||
awards.register_achievement("award_sam_the_trapper",{
|
awards.register_achievement("award_sam_the_trapper",{
|
||||||
title = S("Sam the Trapper"),
|
title = S("Sam the Trapper"),
|
||||||
description = S("Place 2 trap stones."),
|
description = S("Place 2 trap stones."),
|
||||||
icon = "novicebuilder.png",
|
icon = "awards_novicebuilder.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "place",
|
type = "place",
|
||||||
node = "moreblocks:trap_stone",
|
node = "moreblocks:trap_stone",
|
||||||
@ -91,12 +93,68 @@ if minetest.get_modpath("moreblocks") then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
awards.register_achievement("awards_stonebrick", {
|
||||||
|
title = S("Home Improvement"),
|
||||||
|
description = S("Craft 200 stone bricks."),
|
||||||
|
icon = "default_stone_brick.png",
|
||||||
|
trigger = {
|
||||||
|
type = "craft",
|
||||||
|
item = "default:stonebrick",
|
||||||
|
target = 200
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
awards.register_achievement("awards_desert_stonebrick", {
|
||||||
|
title = S("Desert Dweller"),
|
||||||
|
description = S("Craft 400 desert stone bricks."),
|
||||||
|
icon = "default_desert_stone_brick.png",
|
||||||
|
trigger = {
|
||||||
|
type = "craft",
|
||||||
|
item = "default:desert_stonebrick",
|
||||||
|
target = 400
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
awards.register_achievement("awards_desertstonebrick", {
|
||||||
|
title = S("Pharaoh"),
|
||||||
|
description = S("Craft 100 sandstone bricks."),
|
||||||
|
icon = "default_sandstone_brick.png",
|
||||||
|
trigger = {
|
||||||
|
type = "craft",
|
||||||
|
item = "default:sandstonebrick",
|
||||||
|
target = 100
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
awards.register_achievement("awards_bookshelf", {
|
||||||
|
title = S("Little Library"),
|
||||||
|
description = S("Craft 7 bookshelves."),
|
||||||
|
icon = "default_bookshelf.png",
|
||||||
|
trigger = {
|
||||||
|
type = "craft",
|
||||||
|
item = "default:bookshelf",
|
||||||
|
target = 7
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
awards.register_achievement("awards_obsidian", {
|
||||||
|
title = S("Lava and Water"),
|
||||||
|
description = S("Mine your first obsidian."),
|
||||||
|
icon = "default_obsidian.png",
|
||||||
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "default:obsidian",
|
||||||
|
target = 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
-- Obsessed with Obsidian
|
-- Obsessed with Obsidian
|
||||||
awards.register_achievement("award_obsessed_with_obsidian",{
|
awards.register_achievement("award_obsessed_with_obsidian",{
|
||||||
title = S("Obsessed with Obsidian"),
|
title = S("Obsessed with Obsidian"),
|
||||||
description = S("Mine 50 obsidian."),
|
description = S("Mine 50 obsidian."),
|
||||||
icon = "miniminer.png",
|
icon = "awards_miniminer.png",
|
||||||
background = "bg_mining.png",
|
background = "awards_bg_mining.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "dig",
|
type = "dig",
|
||||||
node = "default:obsidian",
|
node = "default:obsidian",
|
||||||
@ -108,7 +166,7 @@ awards.register_achievement("award_obsessed_with_obsidian",{
|
|||||||
awards.register_achievement("award_on_the_way", {
|
awards.register_achievement("award_on_the_way", {
|
||||||
title = S("On The Way"),
|
title = S("On The Way"),
|
||||||
description = S("Place 100 rails."),
|
description = S("Place 100 rails."),
|
||||||
icon = "novicebuilder.png",
|
icon = "awards_novicebuilder.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "place",
|
type = "place",
|
||||||
node = "default:rail",
|
node = "default:rail",
|
||||||
@ -191,9 +249,9 @@ awards.register_achievement("award_jungleman", {
|
|||||||
-- Found some Mese!
|
-- Found some Mese!
|
||||||
awards.register_achievement("award_mesefind", {
|
awards.register_achievement("award_mesefind", {
|
||||||
title = S("First Mese Find"),
|
title = S("First Mese Find"),
|
||||||
description = S("Find some Mese."),
|
description = S("Mine your first mese ore."),
|
||||||
icon = "default_mese_block.png",
|
icon = "default_stone.png^default_mineral_mese.png",
|
||||||
background = "bg_mining.png",
|
background = "awards_bg_mining.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "dig",
|
type = "dig",
|
||||||
node = "default:stone_with_mese",
|
node = "default:stone_with_mese",
|
||||||
@ -201,12 +259,28 @@ awards.register_achievement("award_mesefind", {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Mese Block
|
||||||
|
awards.register_achievement("award_meseblock", {
|
||||||
|
secret = true,
|
||||||
|
title = S("Mese Mastery"),
|
||||||
|
description = S("Mine a mese block."),
|
||||||
|
icon = "default_mese_block.png",
|
||||||
|
background = "bg_mining.png",
|
||||||
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "default:mese",
|
||||||
|
target = 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- You're a copper
|
-- You're a copper
|
||||||
awards.register_achievement("award_youre_a_copper", {
|
awards.register_achievement("award_youre_a_copper", {
|
||||||
title = S("You're a copper"),
|
title = S("You're a copper"),
|
||||||
description = S("Dig 1,000 copper ores."),
|
description = S("Dig 1,000 copper ores."),
|
||||||
icon = "miniminer.png",
|
icon = "awards_miniminer.png",
|
||||||
background = "bg_mining.png",
|
background = "awards_bg_mining.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "dig",
|
type = "dig",
|
||||||
node = "default:stone_with_copper",
|
node = "default:stone_with_copper",
|
||||||
@ -216,8 +290,9 @@ awards.register_achievement("award_youre_a_copper", {
|
|||||||
|
|
||||||
-- Found a Nyan cat!
|
-- Found a Nyan cat!
|
||||||
awards.register_achievement("award_nyanfind", {
|
awards.register_achievement("award_nyanfind", {
|
||||||
title = S("OMG, Nyan Cat!"),
|
secret = true,
|
||||||
description = S("Find a nyan cat."),
|
title = S("A Cat in a Pop-Tart?!"),
|
||||||
|
description = S("Mine a nyan cat."),
|
||||||
icon = "nyancat_front.png",
|
icon = "nyancat_front.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "dig",
|
type = "dig",
|
||||||
@ -230,8 +305,8 @@ awards.register_achievement("award_nyanfind", {
|
|||||||
awards.register_achievement("award_mine2", {
|
awards.register_achievement("award_mine2", {
|
||||||
title = S("Mini Miner"),
|
title = S("Mini Miner"),
|
||||||
description = S("Dig 100 stone blocks."),
|
description = S("Dig 100 stone blocks."),
|
||||||
icon = "miniminer.png",
|
icon = "awards_miniminer.png",
|
||||||
background = "bg_mining.png",
|
background = "awards_bg_mining.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "dig",
|
type = "dig",
|
||||||
node = "default:stone",
|
node = "default:stone",
|
||||||
@ -242,9 +317,9 @@ awards.register_achievement("award_mine2", {
|
|||||||
-- Hardened Miner
|
-- Hardened Miner
|
||||||
awards.register_achievement("award_mine3", {
|
awards.register_achievement("award_mine3", {
|
||||||
title = S("Hardened Miner"),
|
title = S("Hardened Miner"),
|
||||||
description = S("Dig 1,000 stone blocks"),
|
description = S("Dig 1,000 stone blocks."),
|
||||||
icon = "miniminer.png",
|
icon = "awards_miniminer.png",
|
||||||
background = "bg_mining.png",
|
background = "awards_bg_mining.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "dig",
|
type = "dig",
|
||||||
node = "default:stone",
|
node = "default:stone",
|
||||||
@ -256,8 +331,8 @@ awards.register_achievement("award_mine3", {
|
|||||||
awards.register_achievement("award_mine4", {
|
awards.register_achievement("award_mine4", {
|
||||||
title = S("Master Miner"),
|
title = S("Master Miner"),
|
||||||
description = S("Dig 10,000 stone blocks."),
|
description = S("Dig 10,000 stone blocks."),
|
||||||
icon = "miniminer.png",
|
icon = "awards_miniminer.png",
|
||||||
background = "bg_mining.png",
|
background = "awards_bg_mining.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "dig",
|
type = "dig",
|
||||||
node = "default:stone",
|
node = "default:stone",
|
||||||
@ -269,7 +344,8 @@ awards.register_achievement("award_mine4", {
|
|||||||
awards.register_achievement("award_marchand_de_sable", {
|
awards.register_achievement("award_marchand_de_sable", {
|
||||||
title = S("Marchand De Sable"),
|
title = S("Marchand De Sable"),
|
||||||
description = S("Dig 1,000 sand."),
|
description = S("Dig 1,000 sand."),
|
||||||
background = "bg_mining.png",
|
icon = "default_sand.png",
|
||||||
|
background = "awards_bg_mining.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "dig",
|
type = "dig",
|
||||||
node = "default:sand",
|
node = "default:sand",
|
||||||
@ -279,7 +355,8 @@ awards.register_achievement("award_marchand_de_sable", {
|
|||||||
|
|
||||||
awards.register_achievement("awards_crafter_of_sticks", {
|
awards.register_achievement("awards_crafter_of_sticks", {
|
||||||
title = S("Crafter of Sticks"),
|
title = S("Crafter of Sticks"),
|
||||||
description = S("Create 100 Sticks"),
|
description = S("Craft 100 sticks."),
|
||||||
|
icon = "default_stick.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "craft",
|
type = "craft",
|
||||||
item = "default:stick",
|
item = "default:stick",
|
||||||
@ -287,124 +364,145 @@ awards.register_achievement("awards_crafter_of_sticks", {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Join
|
awards.register_achievement("awards_junglegrass", {
|
||||||
awards.register_achievement("award_join2", {
|
title = S("Jungle Discoverer"),
|
||||||
title = S("Frequent Visitor"),
|
description = S("Mine your first jungle grass."),
|
||||||
description = S("Connect to the server 50 times."),
|
icon = "default_junglegrass.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "join",
|
type = "dig",
|
||||||
target = 50
|
node = "default:junglegrass",
|
||||||
},
|
target = 1
|
||||||
secret = true
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Dying Spree
|
|
||||||
awards.register_achievement("award_dying_spree", {
|
|
||||||
title = S("Dying Spree"),
|
|
||||||
description = S("Die 5 times."),
|
|
||||||
trigger = {
|
|
||||||
type = "death",
|
|
||||||
target = 5
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Bot-like
|
awards.register_achievement("awards_grass", {
|
||||||
awards.register_achievement("award_bot_like", {
|
title = S("Grasslands Discoverer"),
|
||||||
title = S("Bot-like"),
|
description = S("Mine some grass."),
|
||||||
description = S("Die 10 times."),
|
icon = "default_grass_3.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "death",
|
type = "dig",
|
||||||
target = 10
|
node = "default:grass_1",
|
||||||
|
target = 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- You Suck!
|
awards.register_achievement("awards_dry_grass", {
|
||||||
awards.register_achievement("award_you_suck", {
|
title = S("Savannah Discoverer"),
|
||||||
title = S("You Suck!"),
|
description = S("Mine some dry grass."),
|
||||||
description = S("Die 100 times."),
|
icon = "default_dry_grass_3.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "death",
|
type = "dig",
|
||||||
target = 100
|
node = "default:dry_grass_3",
|
||||||
},
|
target = 1
|
||||||
secret = true
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Burned to death
|
awards.register_achievement("awards_cactus", {
|
||||||
awards.register_achievement("award_burn", {
|
title = S("Desert Discoverer"),
|
||||||
title = S("You're a witch!"),
|
description = S("Mine your first cactus."),
|
||||||
description = S("Burn to death in a fire.")
|
icon = "default_cactus_side.png",
|
||||||
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "default:cactus",
|
||||||
|
target = 1
|
||||||
|
}
|
||||||
})
|
})
|
||||||
awards.register_onDeath(function(player,data)
|
|
||||||
local pos = player:getpos()
|
|
||||||
if pos and minetest.find_node_near(pos, 2, "fire:basic_flame") ~= nil then
|
|
||||||
return "award_burn"
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Died in flowing lava
|
awards.register_achievement("awards_dry_shrub", {
|
||||||
awards.register_achievement("award_in_the_flow", {
|
title = S("Far Lands"),
|
||||||
title = S("In the Flow"),
|
description = S("Mine your first dry shrub."),
|
||||||
description = S("Die in flowing lava.")
|
icon = "default_dry_shrub.png",
|
||||||
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "default:dry_shrub",
|
||||||
|
target = 1
|
||||||
|
}
|
||||||
})
|
})
|
||||||
awards.register_onDeath(function(player,data)
|
|
||||||
local pos = player:getpos()
|
|
||||||
if pos and minetest.find_node_near(pos, 2, "default:lava_flowing") ~= nil then
|
|
||||||
return "award_in_the_flow"
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Die near diamond ore
|
awards.register_achievement("awards_farmer", {
|
||||||
awards.register_achievement("award_this_is_sad", {
|
title = S("Farmer"),
|
||||||
title = S("This is Sad"),
|
description = S("Dig a fully grown wheat plant."),
|
||||||
description = S("Die near diamond ore.")
|
icon = "farming_wheat_8.png",
|
||||||
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "farming:wheat_8",
|
||||||
|
target = 1
|
||||||
|
}
|
||||||
})
|
})
|
||||||
awards.register_on_death(function(player,data)
|
|
||||||
local pos = player:getpos()
|
|
||||||
if pos and minetest.find_node_near(pos, 5, "default:stone_with_diamond") ~= nil then
|
|
||||||
return "award_this_is_sad"
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Die near diamond ore
|
awards.register_achievement("awards_ice", {
|
||||||
awards.register_achievement("award_the_stack", {
|
title = S("Glacier Discoverer"),
|
||||||
title = S("The Stack"),
|
description = S("Mine your first ice."),
|
||||||
description = S("Die near bones.")
|
icon = "default_ice.png",
|
||||||
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "default:ice",
|
||||||
|
target = 1
|
||||||
|
}
|
||||||
})
|
})
|
||||||
awards.register_on_death(function(player,data)
|
|
||||||
local pos = player:getpos()
|
|
||||||
if pos and minetest.find_node_near(pos, 5, "bones:bones") ~= nil then
|
|
||||||
return "award_the_stack"
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Die near diamond ore
|
awards.register_achievement("awards_gold_ore", {
|
||||||
awards.register_achievement("award_deep_down", {
|
title = S("First Gold Find"),
|
||||||
title = S("Deep Down"),
|
description = S("Mine your first gold ore."),
|
||||||
description = S("Die below -10000"),
|
icon = "default_stone.png^default_mineral_gold.png",
|
||||||
secret = true
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "default:stone_with_gold",
|
||||||
|
target = 1
|
||||||
|
}
|
||||||
})
|
})
|
||||||
awards.register_on_death(function(player,data)
|
|
||||||
local pos = player:getpos()
|
|
||||||
if pos and pos.y < -10000 then
|
|
||||||
return "award_deep_down"
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Die near diamond ore
|
awards.register_achievement("awards_gold_rush", {
|
||||||
awards.register_achievement("award_no_screen", {
|
title = S("Gold Rush"),
|
||||||
title = S("In space, no one can hear you scream"),
|
description = S("Mine 45 gold ores."),
|
||||||
description = S("Die above 10000"),
|
icon = "default_stone.png^default_mineral_gold.png",
|
||||||
secret = true
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "default:stone_with_gold",
|
||||||
|
target = 45
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
awards.register_achievement("awards_diamond_ore", {
|
||||||
|
title = S("Wow, I am Diamonds!"),
|
||||||
|
description = S("Mine your first diamond ore."),
|
||||||
|
icon = "default_stone.png^default_mineral_diamond.png",
|
||||||
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "default:stone_with_diamond",
|
||||||
|
target = 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
awards.register_achievement("awards_diamond_rush", {
|
||||||
|
title = S("Girl's Best Friend"),
|
||||||
|
description = S("Mine 18 diamond ores."),
|
||||||
|
icon = "default_stone.png^default_mineral_diamond.png",
|
||||||
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "default:stone_with_diamond",
|
||||||
|
target = 18
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
awards.register_achievement("awards_diamondblock", {
|
||||||
|
title = S("Hardest Block on Earth"),
|
||||||
|
description = S("Craft a diamond block."),
|
||||||
|
icon = "default_diamond_block.png",
|
||||||
|
trigger = {
|
||||||
|
type = "craft",
|
||||||
|
item = "default:diamondblock",
|
||||||
|
target = 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
awards.register_achievement("awards_mossycobble", {
|
||||||
|
title = S("In the Dungeon"),
|
||||||
|
description = S("Mine a mossy cobblestone."),
|
||||||
|
icon = "default_mossycobble.png",
|
||||||
|
trigger = {
|
||||||
|
type = "dig",
|
||||||
|
node = "default:mossycobble",
|
||||||
|
target = 1
|
||||||
|
}
|
||||||
})
|
})
|
||||||
awards.register_on_death(function(player,data)
|
|
||||||
local pos = player:getpos()
|
|
||||||
if pos and pos.y > 10000 then
|
|
||||||
return "award_no_screen"
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end)
|
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
Achievement Unlocked: =
|
Achievement Unlocked: =
|
||||||
|
Secret Achievement Unlocked: =
|
||||||
|
Achievement Unlocked: %s =
|
||||||
|
Secret Achievement Unlocked: %s =
|
||||||
|
Achievement Unlocked! =
|
||||||
|
Secret Achievement Unlocked! =
|
||||||
Light It Up =
|
Light It Up =
|
||||||
Place 100 torches. =
|
Place 100 torches. =
|
||||||
Light ALL The Things! =
|
Light ALL The Things! =
|
||||||
@ -59,3 +64,4 @@ Deep Down =
|
|||||||
Die below -10000 =
|
Die below -10000 =
|
||||||
In space, no one can hear you scream =
|
In space, no one can hear you scream =
|
||||||
Die above 10000 =
|
Die above 10000 =
|
||||||
|
Awards =
|
||||||
|
2
mod.conf
@ -4,4 +4,4 @@ author = rubenwardy
|
|||||||
description = Adds achievements to Minetest, and an API to register new ones.
|
description = Adds achievements to Minetest, and an API to register new ones.
|
||||||
license = LGPL 2.1 or later
|
license = LGPL 2.1 or later
|
||||||
forum = https://forum.minetest.net/viewtopic.php?t=4870
|
forum = https://forum.minetest.net/viewtopic.php?t=4870
|
||||||
version = 2.1.1
|
version = 2.3.0
|
||||||
|
23
sfinv.lua
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
if minetest.get_modpath("sfinv") then
|
||||||
|
sfinv.register_page("awards:awards", {
|
||||||
|
title = "Awards",
|
||||||
|
on_enter = function(self, player, context)
|
||||||
|
context.awards_idx = 1
|
||||||
|
end,
|
||||||
|
get = function(self, player, context)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
return sfinv.make_formspec(player, context,
|
||||||
|
awards.getFormspec(name, name, context.awards_idx or 1),
|
||||||
|
false, "size[11,5]")
|
||||||
|
end,
|
||||||
|
on_player_receive_fields = function(self, player, context, fields)
|
||||||
|
if fields.awards then
|
||||||
|
local event = minetest.explode_textlist_event(fields.awards)
|
||||||
|
if event.type == "CHG" then
|
||||||
|
context.awards_idx = event.index
|
||||||
|
sfinv.set(player, context)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 564 B After Width: | Height: | Size: 564 B |
Before Width: | Height: | Size: 455 B After Width: | Height: | Size: 455 B |
Before Width: | Height: | Size: 374 B After Width: | Height: | Size: 374 B |
BIN
textures/awards_progress_gray.png
Normal file
After Width: | Height: | Size: 146 B |
BIN
textures/awards_progress_green.png
Normal file
After Width: | Height: | Size: 177 B |
Before Width: | Height: | Size: 322 B After Width: | Height: | Size: 322 B |
BIN
textures/awards_ui_icon.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 322 B After Width: | Height: | Size: 322 B |
45
triggers.lua
@ -21,6 +21,13 @@ awards.register_trigger("dig", function(def)
|
|||||||
target = def.trigger.target
|
target = def.trigger.target
|
||||||
}
|
}
|
||||||
table.insert(awards.on.dig, tmp)
|
table.insert(awards.on.dig, tmp)
|
||||||
|
def.getProgress = function(self, data)
|
||||||
|
local itemcount = awards.get_item_count(data, "count", tmp.node) or 0
|
||||||
|
return {
|
||||||
|
perc = itemcount / tmp.target,
|
||||||
|
label = itemcount .. " / " .. tmp.target .. " dug" -- TODO: translation
|
||||||
|
}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
awards.register_trigger("place", function(def)
|
awards.register_trigger("place", function(def)
|
||||||
@ -30,6 +37,13 @@ awards.register_trigger("place", function(def)
|
|||||||
target = def.trigger.target
|
target = def.trigger.target
|
||||||
}
|
}
|
||||||
table.insert(awards.on.place, tmp)
|
table.insert(awards.on.place, tmp)
|
||||||
|
def.getProgress = function(self, data)
|
||||||
|
local itemcount = awards.get_item_count(data, "place", tmp.node) or 0
|
||||||
|
return {
|
||||||
|
perc = itemcount / tmp.target,
|
||||||
|
label = itemcount .. " / " .. tmp.target .. " placed" -- TODO: translation
|
||||||
|
}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
awards.register_trigger("death", function(def)
|
awards.register_trigger("death", function(def)
|
||||||
@ -38,6 +52,13 @@ awards.register_trigger("death", function(def)
|
|||||||
target = def.trigger.target
|
target = def.trigger.target
|
||||||
}
|
}
|
||||||
table.insert(awards.on.death, tmp)
|
table.insert(awards.on.death, tmp)
|
||||||
|
def.getProgress = function(self, data)
|
||||||
|
local itemcount = data.deaths or 0
|
||||||
|
return {
|
||||||
|
perc = itemcount / tmp.target,
|
||||||
|
label = itemcount .. " deaths, need " .. tmp.target -- TODO: translation
|
||||||
|
}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
awards.register_trigger("chat", function(def)
|
awards.register_trigger("chat", function(def)
|
||||||
@ -46,6 +67,13 @@ awards.register_trigger("chat", function(def)
|
|||||||
target = def.trigger.target
|
target = def.trigger.target
|
||||||
}
|
}
|
||||||
table.insert(awards.on.chat, tmp)
|
table.insert(awards.on.chat, tmp)
|
||||||
|
def.getProgress = function(self, data)
|
||||||
|
local itemcount = data.chats or 0
|
||||||
|
return {
|
||||||
|
perc = itemcount / tmp.target,
|
||||||
|
label = itemcount .. " / " .. tmp.target .. " line of chat" -- TODO: translation
|
||||||
|
}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
awards.register_trigger("join", function(def)
|
awards.register_trigger("join", function(def)
|
||||||
@ -54,6 +82,14 @@ awards.register_trigger("join", function(def)
|
|||||||
target = def.trigger.target
|
target = def.trigger.target
|
||||||
}
|
}
|
||||||
table.insert(awards.on.join, tmp)
|
table.insert(awards.on.join, tmp)
|
||||||
|
|
||||||
|
def.getProgress = function(self, data)
|
||||||
|
local itemcount = data.joins or 0
|
||||||
|
return {
|
||||||
|
perc = itemcount / tmp.target,
|
||||||
|
label = itemcount .. " game joins, need " .. tmp.target -- TODO: translation
|
||||||
|
}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
awards.register_trigger("craft", function(def)
|
awards.register_trigger("craft", function(def)
|
||||||
@ -63,6 +99,13 @@ awards.register_trigger("craft", function(def)
|
|||||||
target = def.trigger.target
|
target = def.trigger.target
|
||||||
}
|
}
|
||||||
table.insert(awards.on.craft, tmp)
|
table.insert(awards.on.craft, tmp)
|
||||||
|
def.getProgress = function(self, data)
|
||||||
|
local itemcount = awards.get_item_count(data, "craft", tmp.item) or 0
|
||||||
|
return {
|
||||||
|
perc = itemcount / tmp.target,
|
||||||
|
label = itemcount .. " / " .. tmp.target .. " crafted" -- TODO: translation
|
||||||
|
}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Backwards compatibility
|
-- Backwards compatibility
|
||||||
@ -126,7 +169,7 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
|
|||||||
end
|
end
|
||||||
|
|
||||||
local data = awards.players[player:get_player_name()]
|
local data = awards.players[player:get_player_name()]
|
||||||
if not awards.increment_item_counter(data, "craft", itemstack:get_name()) then
|
if not awards.increment_item_counter(data, "craft", itemstack:get_name(), itemstack:get_count()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
19
unified_inventory.lua
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
if minetest.get_modpath("unified_inventory") ~= nil then
|
||||||
|
local S
|
||||||
|
if (intllib) then
|
||||||
|
dofile(minetest.get_modpath("intllib").."/intllib.lua")
|
||||||
|
S = intllib.Getter(minetest.get_current_modname())
|
||||||
|
else
|
||||||
|
S = function ( s ) return s end
|
||||||
|
end
|
||||||
|
|
||||||
|
unified_inventory.register_button("awards", {
|
||||||
|
type = "image",
|
||||||
|
image = "awards_ui_icon.png",
|
||||||
|
tooltip = S("Awards"),
|
||||||
|
action = function(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
awards.show_to(name, name, nil, false)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|