diff options
author | Andrew Ward <anjayward@gmail.com> | 2013-02-26 05:23:36 -0800 |
---|---|---|
committer | Andrew Ward <anjayward@gmail.com> | 2013-02-26 05:23:36 -0800 |
commit | f9ec33fb1b410ccbd08deb857f319e2c288c179e (patch) | |
tree | 05971bb90262ef4d00144aec2af54d750768eae1 | |
parent | 5cd8bfb491736c7e2140484bb6aff766dda1acbc (diff) | |
parent | dd3de62572c61c803f051d40b5ab9853ade81370 (diff) |
Merge pull request #1 from Traxie21/master
Formspec addition
-rw-r--r-- | api.lua | 35 | ||||
-rw-r--r-- | config.txt | 8 | ||||
-rw-r--r-- | init.lua | 17 | ||||
-rw-r--r-- | textures/bg_default.png | bin | 0 -> 31407 bytes | |||
-rw-r--r-- | textures/bg_mining.png | bin | 0 -> 21274 bytes | |||
-rw-r--r-- | textures/mese.png | bin | 0 -> 564 bytes | |||
-rw-r--r-- | textures/miniminer.png | bin | 0 -> 455 bytes | |||
-rw-r--r-- | textures/novicebuilder.png | bin | 0 -> 374 bytes | |||
-rw-r--r-- | textures/template.png | bin | 0 -> 322 bytes | |||
-rw-r--r-- | textures/unknown.png | bin | 0 -> 322 bytes |
10 files changed, 49 insertions, 11 deletions
@@ -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 - 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) + if desc~="" then + minetest.chat_send_player(name, desc) + end end - + print(name.." Has unlocked"..title..".") -- save playertable save_playerD() end diff --git a/config.txt b/config.txt new file mode 100644 index 0000000..9fe580e --- /dev/null +++ b/config.txt @@ -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)
\ No newline at end of file @@ -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", diff --git a/textures/bg_default.png b/textures/bg_default.png Binary files differnew file mode 100644 index 0000000..a6f57d3 --- /dev/null +++ b/textures/bg_default.png diff --git a/textures/bg_mining.png b/textures/bg_mining.png Binary files differnew file mode 100644 index 0000000..a698779 --- /dev/null +++ b/textures/bg_mining.png diff --git a/textures/mese.png b/textures/mese.png Binary files differnew file mode 100644 index 0000000..3fc800e --- /dev/null +++ b/textures/mese.png diff --git a/textures/miniminer.png b/textures/miniminer.png Binary files differnew file mode 100644 index 0000000..45c7238 --- /dev/null +++ b/textures/miniminer.png diff --git a/textures/novicebuilder.png b/textures/novicebuilder.png Binary files differnew file mode 100644 index 0000000..f24d843 --- /dev/null +++ b/textures/novicebuilder.png diff --git a/textures/template.png b/textures/template.png Binary files differnew file mode 100644 index 0000000..b290454 --- /dev/null +++ b/textures/template.png diff --git a/textures/unknown.png b/textures/unknown.png Binary files differnew file mode 100644 index 0000000..b290454 --- /dev/null +++ b/textures/unknown.png |