mirror of
https://gitlab.com/rubenwardy/awards.git
synced 2024-12-28 03:30:40 +01:00
Rename awards.def to awards.registered_awards
This commit is contained in:
parent
5de9dcb797
commit
72cc346c35
8
api.lua
8
api.lua
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
local S, NS = awards.gettext, awards.ngettext
|
local S, NS = awards.gettext, awards.ngettext
|
||||||
|
|
||||||
awards.def = {}
|
awards.registered_awards = {}
|
||||||
awards.on = {}
|
awards.on = {}
|
||||||
awards.on_unlock = {}
|
awards.on_unlock = {}
|
||||||
|
|
||||||
@ -205,9 +205,9 @@ function awards.register_achievement(name, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Add Award
|
-- Add Award
|
||||||
awards.def[name] = def
|
awards.registered_awards[name] = def
|
||||||
|
|
||||||
local tdef = awards.def[name]
|
local tdef = awards.registered_awards[name]
|
||||||
if def.description == nil and tdef.getDefaultDescription then
|
if def.description == nil and tdef.getDefaultDescription then
|
||||||
def.description = tdef:getDefaultDescription()
|
def.description = tdef:getDefaultDescription()
|
||||||
end
|
end
|
||||||
@ -241,7 +241,7 @@ end
|
|||||||
function awards.unlock(name, award)
|
function awards.unlock(name, award)
|
||||||
-- Access Player Data
|
-- Access Player Data
|
||||||
local data = awards.player(name)
|
local data = awards.player(name)
|
||||||
local awdef = awards.def[award]
|
local awdef = awards.registered_awards[award]
|
||||||
assert(awdef, "Unable to unlock an award which doesn't exist!")
|
assert(awdef, "Unable to unlock an award which doesn't exist!")
|
||||||
|
|
||||||
if data.disabled or
|
if data.disabled or
|
||||||
|
@ -42,7 +42,7 @@ minetest.register_chatcommand("awd", {
|
|||||||
params = S("<achievement ID>"),
|
params = S("<achievement ID>"),
|
||||||
description = S("Show details of an achievement"),
|
description = S("Show details of an achievement"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local def = awards.def[param]
|
local def = awards.registered_awards[param]
|
||||||
if def then
|
if def then
|
||||||
minetest.chat_send_player(name, string.format(S("%s: %s"), def.title, def.description))
|
minetest.chat_send_player(name, string.format(S("%s: %s"), def.title, def.description))
|
||||||
else
|
else
|
||||||
|
10
gui.lua
10
gui.lua
@ -6,13 +6,13 @@ local function order_awards(name)
|
|||||||
local player = awards.player(name)
|
local player = awards.player(name)
|
||||||
if player and player.unlocked then
|
if player and player.unlocked then
|
||||||
for _,got in pairs(player.unlocked) do
|
for _,got in pairs(player.unlocked) do
|
||||||
if awards.def[got] then
|
if awards.registered_awards[got] then
|
||||||
done[got] = true
|
done[got] = true
|
||||||
table.insert(retval,{name=got,got=true})
|
table.insert(retval,{name=got,got=true})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _,def in pairs(awards.def) do
|
for _,def in pairs(awards.registered_awards) do
|
||||||
if not done[def.name] then
|
if not done[def.name] then
|
||||||
table.insert(retval,{name=def.name,got=false})
|
table.insert(retval,{name=def.name,got=false})
|
||||||
end
|
end
|
||||||
@ -34,7 +34,7 @@ function awards.get_formspec(name, to, sid)
|
|||||||
-- 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.registered_awards[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;"..minetest.formspec_escape(S("(Secret Award)")).."]"..
|
formspec = formspec .. "label[1,2.75;"..minetest.formspec_escape(S("(Secret Award)")).."]"..
|
||||||
@ -87,7 +87,7 @@ function awards.get_formspec(name, to, sid)
|
|||||||
formspec = formspec .. "textlist[4.75,0;6,5;awards;"
|
formspec = formspec .. "textlist[4.75,0;6,5;awards;"
|
||||||
local first = true
|
local first = true
|
||||||
for _,award in pairs(listofawards) do
|
for _,award in pairs(listofawards) do
|
||||||
local def = awards.def[award.name]
|
local def = awards.registered_awards[award.name]
|
||||||
if def then
|
if def then
|
||||||
if not first then
|
if not first then
|
||||||
formspec = formspec .. ","
|
formspec = formspec .. ","
|
||||||
@ -134,7 +134,7 @@ function awards.show_to(name, to, sid, text)
|
|||||||
minetest.chat_send_player(to, string.format(S("%s’s awards:"), name))
|
minetest.chat_send_player(to, string.format(S("%s’s awards:"), name))
|
||||||
|
|
||||||
for _, str in pairs(data.unlocked) do
|
for _, str in pairs(data.unlocked) do
|
||||||
local def = awards.def[str]
|
local def = awards.registered_awards[str]
|
||||||
if def then
|
if def then
|
||||||
if def.title then
|
if def.title then
|
||||||
if def.description then
|
if def.description then
|
||||||
|
1
init.lua
1
init.lua
@ -40,6 +40,7 @@ awards.register_onDeath = awards.register_on_death
|
|||||||
awards.register_onChat = awards.register_on_chat
|
awards.register_onChat = awards.register_on_chat
|
||||||
awards.register_onJoin = awards.register_on_join
|
awards.register_onJoin = awards.register_on_join
|
||||||
awards.register_onCraft = awards.register_on_craft
|
awards.register_onCraft = awards.register_on_craft
|
||||||
|
awards.def = awards.registered_awards
|
||||||
|
|
||||||
awards.register_achievement("award_saint_maclou",{
|
awards.register_achievement("award_saint_maclou",{
|
||||||
title = "Saint-Maclou",
|
title = "Saint-Maclou",
|
||||||
|
Loading…
Reference in New Issue
Block a user