diff options
author | Wuzzy <almikes@aol.com> | 2016-09-01 18:45:59 +0200 |
---|---|---|
committer | rubenwardy <rubenwardy@gmail.com> | 2016-09-10 15:38:01 +0100 |
commit | ae01ea01dd80ae40a8289e57908586ec70bfa5b6 (patch) | |
tree | cdfe4e038cd48ad6c7459f89ab70c169a8e46725 /api.lua | |
parent | a04f3df1e2996706c23d8562d2684a41a7215a05 (diff) |
Show error messages when there are no awards
Diffstat (limited to 'api.lua')
-rw-r--r-- | api.lua | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -341,10 +341,17 @@ function awards.getFormspec(name, to, sid) local listofawards = awards._order_awards(name) local playerdata = awards.players[name] + if #listofawards == 0 then + formspec = formspec .. "label[3.9,1.5;"..minetest.formspec_escape(S("Error: No awards available.")).."]" + formspec = formspec .. "button_exit[4.2,2.3;3,1;close;"..minetest.formspec_escape(S("OK")).."]" + return formspec + end + -- Sidebar if sid then local item = listofawards[sid+0] local def = awards.def[item.name] + if def and def.secret and not item.got then formspec = formspec .. "label[1,2.75;"..minetest.formspec_escape(S("(Secret Award)")).."]".. "image[1,0;3,3;awards_unknown.png]" @@ -428,8 +435,12 @@ function awards.show_to(name, to, sid, text) return end if text then - if not awards.players[name] or not awards.players[name].unlocked then - minetest.chat_send_player(to, S("You have not unlocked any awards")) + local listofawards = awards._order_awards(name) + if #listofawards == 0 then + minetest.chat_send_player(to, S("Error: No awards available.")) + return + elseif not awards.players[name] or not awards.players[name].unlocked then + minetest.chat_send_player(to, S("You have not unlocked any awards.")) return end minetest.chat_send_player(to, string.format(S("%s’s awards:"), name)) @@ -454,7 +465,8 @@ function awards.show_to(name, to, sid, text) end -- Show formspec to user minetest.show_formspec(to,"awards:awards", - "size[11,5]" .. awards.getFormspec(name, to, sid)) + "size[11,5]" .. default.gui_bg .. default.gui_bg_img .. + awards.getFormspec(name, to, sid)) end end awards.showto = awards.show_to |