-Added formspec system
-Added 3 new api values for formspec (background, icon, and custom_announce) -Added configuration file -Fixed one glitch that happens when you mine stone and rejoin -Addded textures
35
api.lua
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
-- Table Save Load Functions
|
-- Table Save Load Functions
|
||||||
local function save_playerD()
|
function save_playerD()
|
||||||
local file = io.open(minetest.get_worldpath().."/awards.txt", "w")
|
local file = io.open(minetest.get_worldpath().."/awards.txt", "w")
|
||||||
if file then
|
if file then
|
||||||
file:write(minetest.serialize(player_data))
|
file:write(minetest.serialize(player_data))
|
||||||
|
@ -28,6 +28,7 @@ awards.def={}
|
||||||
|
|
||||||
-- Load files
|
-- Load files
|
||||||
dofile(minetest.get_modpath("awards").."/triggers.lua")
|
dofile(minetest.get_modpath("awards").."/triggers.lua")
|
||||||
|
dofile(minetest.get_modpath("awards").."/config.txt")
|
||||||
|
|
||||||
-- API Functions
|
-- API Functions
|
||||||
function awards.register_achievement(name,data_table)
|
function awards.register_achievement(name,data_table)
|
||||||
|
@ -53,8 +54,17 @@ function awards.register_achievement(name,data_table)
|
||||||
}
|
}
|
||||||
table.insert(awards.onDeath,tmp)
|
table.insert(awards.onDeath,tmp)
|
||||||
end
|
end
|
||||||
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
|
awards['def'][name] = data_table
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -86,8 +96,11 @@ function awards.give_achievement(name,award)
|
||||||
local desc = ""
|
local desc = ""
|
||||||
|
|
||||||
-- check definition table
|
-- 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']
|
title=awards['def'][award]['title']
|
||||||
|
background=awards['def'][award]['background']
|
||||||
|
icon=awards['def'][award]['icon']
|
||||||
|
custom_announce=awards['def'][award]['custom_announce']
|
||||||
end
|
end
|
||||||
|
|
||||||
if awards['def'][award] and awards['def'][award]['description'] then
|
if awards['def'][award] and awards['def'][award]['description'] then
|
||||||
|
@ -95,13 +108,19 @@ function awards.give_achievement(name,award)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- send award header
|
-- 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)
|
minetest.chat_send_player(name, "Achievement Unlocked: "..title)
|
||||||
|
if desc~="" then
|
||||||
-- send award content
|
minetest.chat_send_player(name, desc)
|
||||||
if desc~="" then
|
end
|
||||||
minetest.chat_send_player(name, desc)
|
|
||||||
end
|
end
|
||||||
|
print(name.." Has unlocked"..title..".")
|
||||||
-- save playertable
|
-- save playertable
|
||||||
save_playerD()
|
save_playerD()
|
||||||
end
|
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",{
|
awards.register_achievement("award_lightitup",{
|
||||||
title = "Light It Up",
|
title = "Light It Up",
|
||||||
description = "You have placed 100 torches",
|
description = "You have placed 100 torches",
|
||||||
|
icon = "novicebuilder.png",
|
||||||
trigger={
|
trigger={
|
||||||
type="place",
|
type="place",
|
||||||
node="default:torch",
|
node="default:torch",
|
||||||
|
@ -32,10 +33,12 @@ awards.register_achievement("award_lumberjack",{
|
||||||
awards.register_achievement("award_mesefind",{
|
awards.register_achievement("award_mesefind",{
|
||||||
title = "First Mese Find",
|
title = "First Mese Find",
|
||||||
description = "Found some Mese!",
|
description = "Found some Mese!",
|
||||||
|
icon = "mese.png",
|
||||||
|
background = "bg_mining.png",
|
||||||
trigger={
|
trigger={
|
||||||
type="dig",
|
type="dig",
|
||||||
node="default:mese",
|
node="default:stone_with_mese",
|
||||||
target=1,
|
target=100,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -52,8 +55,10 @@ awards.register_achievement("award_nyanfind",{
|
||||||
|
|
||||||
-- Just entered the mine
|
-- Just entered the mine
|
||||||
awards.register_achievement("award_mine1",{
|
awards.register_achievement("award_mine1",{
|
||||||
title = "Just Entered the mine",
|
title = "Entering the mine",
|
||||||
description = "You have dug 10 stone blocks",
|
description = "You have dug 10 stone blocks",
|
||||||
|
icon = "miniminer.png",
|
||||||
|
background = "bg_mining.png",
|
||||||
trigger={
|
trigger={
|
||||||
type="dig",
|
type="dig",
|
||||||
node="default:stone",
|
node="default:stone",
|
||||||
|
@ -65,6 +70,8 @@ awards.register_achievement("award_mine1",{
|
||||||
awards.register_achievement("award_mine2",{
|
awards.register_achievement("award_mine2",{
|
||||||
title = "Mini Miner",
|
title = "Mini Miner",
|
||||||
description = "You have dug 100 stone blocks",
|
description = "You have dug 100 stone blocks",
|
||||||
|
icon = "miniminer.png",
|
||||||
|
background = "bg_mining.png",
|
||||||
trigger={
|
trigger={
|
||||||
type="dig",
|
type="dig",
|
||||||
node="default:stone",
|
node="default:stone",
|
||||||
|
@ -76,6 +83,8 @@ awards.register_achievement("award_mine2",{
|
||||||
awards.register_achievement("award_mine3",{
|
awards.register_achievement("award_mine3",{
|
||||||
title = "Hardened Miner",
|
title = "Hardened Miner",
|
||||||
description = "You have dug 1000 stone blocks",
|
description = "You have dug 1000 stone blocks",
|
||||||
|
icon = "miniminer.png",
|
||||||
|
background = "bg_mining.png",
|
||||||
trigger={
|
trigger={
|
||||||
type="dig",
|
type="dig",
|
||||||
node="default:stone",
|
node="default:stone",
|
||||||
|
@ -87,6 +96,8 @@ awards.register_achievement("award_mine3",{
|
||||||
awards.register_achievement("award_mine4",{
|
awards.register_achievement("award_mine4",{
|
||||||
title = "Master Miner",
|
title = "Master Miner",
|
||||||
description = "You have dug 10000 stone blocks",
|
description = "You have dug 10000 stone blocks",
|
||||||
|
icon = "miniminer.png",
|
||||||
|
background = "bg_mining.png",
|
||||||
trigger={
|
trigger={
|
||||||
type="dig",
|
type="dig",
|
||||||
node="default:stone",
|
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 |