29
api.lua
@ -1,6 +1,6 @@
|
||||
|
||||
-- Table Save Load Functions
|
||||
local function save_playerD()
|
||||
function save_playerD()
|
||||
local file = io.open(minetest.get_worldpath().."/awards.txt", "w")
|
||||
if file then
|
||||
file:write(minetest.serialize(player_data))
|
||||
@ -28,6 +28,7 @@ awards.def={}
|
||||
|
||||
-- Load files
|
||||
dofile(minetest.get_modpath("awards").."/triggers.lua")
|
||||
dofile(minetest.get_modpath("awards").."/config.txt")
|
||||
|
||||
-- API Functions
|
||||
function awards.register_achievement(name,data_table)
|
||||
@ -53,8 +54,17 @@ function awards.register_achievement(name,data_table)
|
||||
}
|
||||
table.insert(awards.onDeath,tmp)
|
||||
end
|
||||
if data_table['icon'] == nil or data_table['icon'] == "" then
|
||||
data_table['icon'] = "unknown.png"
|
||||
end
|
||||
if data_table['background'] == nil or data_table['background'] == "" then
|
||||
data_table['background'] = "bg_default.png"
|
||||
end
|
||||
if data_table['custom_announce'] == nil or data_table['custom_announce'] == "" then
|
||||
data_table['custom_announce'] = "Achievement Unlocked:"
|
||||
end
|
||||
|
||||
end
|
||||
awards['def'][name] = data_table
|
||||
end
|
||||
|
||||
@ -86,8 +96,11 @@ function awards.give_achievement(name,award)
|
||||
local desc = ""
|
||||
|
||||
-- check definition table
|
||||
if awards['def'][award] and awards['def'][award]['title'] then
|
||||
if awards['def'][award] and awards['def'][award]['title'] and awards['def'][award]['description'] and awards['def'][award]['icon'] then
|
||||
title=awards['def'][award]['title']
|
||||
background=awards['def'][award]['background']
|
||||
icon=awards['def'][award]['icon']
|
||||
custom_announce=awards['def'][award]['custom_announce']
|
||||
end
|
||||
|
||||
if awards['def'][award] and awards['def'][award]['description'] then
|
||||
@ -95,13 +108,19 @@ function awards.give_achievement(name,award)
|
||||
end
|
||||
|
||||
-- send award header
|
||||
if Use_Formspec == true then
|
||||
minetest.show_formspec(name, "achievements:unlocked", "size[4,2]"..
|
||||
"image_button_exit[0,0;4,2;"..background..";close1; ]"..
|
||||
"image_button_exit[0.2,0.8;1,1;"..icon..";close2; ]"..
|
||||
"label[1.1,1;"..title.."]"..
|
||||
"label[0.3,0.1;"..custom_announce.."]")
|
||||
else
|
||||
minetest.chat_send_player(name, "Achievement Unlocked: "..title)
|
||||
|
||||
-- send award content
|
||||
if desc~="" then
|
||||
minetest.chat_send_player(name, desc)
|
||||
end
|
||||
|
||||
end
|
||||
print(name.." Has unlocked"..title..".")
|
||||
-- save playertable
|
||||
save_playerD()
|
||||
end
|
||||
|
8
config.txt
Normal file
@ -0,0 +1,8 @@
|
||||
-- AWARDS
|
||||
-- by Rubenwardy, CC-BY-SA
|
||||
-------------------------------------------------------
|
||||
-- this is the configuration file for the awards mod
|
||||
-------------------------------------------------------
|
||||
|
||||
Use_Formspec = true
|
||||
--Use a graphical display for unlocking achievements. (Possible values: true | false)
|
17
init.lua
@ -10,6 +10,7 @@ dofile(minetest.get_modpath("awards").."/api.lua")
|
||||
awards.register_achievement("award_lightitup",{
|
||||
title = "Light It Up",
|
||||
description = "You have placed 100 torches",
|
||||
icon = "novicebuilder.png",
|
||||
trigger={
|
||||
type="place",
|
||||
node="default:torch",
|
||||
@ -32,10 +33,12 @@ awards.register_achievement("award_lumberjack",{
|
||||
awards.register_achievement("award_mesefind",{
|
||||
title = "First Mese Find",
|
||||
description = "Found some Mese!",
|
||||
icon = "mese.png",
|
||||
background = "bg_mining.png",
|
||||
trigger={
|
||||
type="dig",
|
||||
node="default:mese",
|
||||
target=1,
|
||||
node="default:stone_with_mese",
|
||||
target=100,
|
||||
},
|
||||
})
|
||||
|
||||
@ -52,8 +55,10 @@ awards.register_achievement("award_nyanfind",{
|
||||
|
||||
-- Just entered the mine
|
||||
awards.register_achievement("award_mine1",{
|
||||
title = "Just Entered the mine",
|
||||
title = "Entering the mine",
|
||||
description = "You have dug 10 stone blocks",
|
||||
icon = "miniminer.png",
|
||||
background = "bg_mining.png",
|
||||
trigger={
|
||||
type="dig",
|
||||
node="default:stone",
|
||||
@ -65,6 +70,8 @@ awards.register_achievement("award_mine1",{
|
||||
awards.register_achievement("award_mine2",{
|
||||
title = "Mini Miner",
|
||||
description = "You have dug 100 stone blocks",
|
||||
icon = "miniminer.png",
|
||||
background = "bg_mining.png",
|
||||
trigger={
|
||||
type="dig",
|
||||
node="default:stone",
|
||||
@ -76,6 +83,8 @@ awards.register_achievement("award_mine2",{
|
||||
awards.register_achievement("award_mine3",{
|
||||
title = "Hardened Miner",
|
||||
description = "You have dug 1000 stone blocks",
|
||||
icon = "miniminer.png",
|
||||
background = "bg_mining.png",
|
||||
trigger={
|
||||
type="dig",
|
||||
node="default:stone",
|
||||
@ -87,6 +96,8 @@ awards.register_achievement("award_mine3",{
|
||||
awards.register_achievement("award_mine4",{
|
||||
title = "Master Miner",
|
||||
description = "You have dug 10000 stone blocks",
|
||||
icon = "miniminer.png",
|
||||
background = "bg_mining.png",
|
||||
trigger={
|
||||
type="dig",
|
||||
node="default:stone",
|
||||
|
BIN
textures/bg_default.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
textures/bg_mining.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
textures/mese.png
Normal file
After Width: | Height: | Size: 564 B |
BIN
textures/miniminer.png
Normal file
After Width: | Height: | Size: 455 B |
BIN
textures/novicebuilder.png
Normal file
After Width: | Height: | Size: 374 B |
BIN
textures/template.png
Normal file
After Width: | Height: | Size: 322 B |
BIN
textures/unknown.png
Normal file
After Width: | Height: | Size: 322 B |