mirror of
https://gitlab.com/rubenwardy/awards.git
synced 2024-11-22 15:23:44 +01:00
More changes
This commit is contained in:
parent
56d08f2f49
commit
628e485900
35
api.lua
35
api.lua
@ -88,11 +88,29 @@ function awards.register_achievement(name, def)
|
||||
awards.def[name] = def
|
||||
end
|
||||
|
||||
function awards.enable(name)
|
||||
local data = awards.player(name)
|
||||
if data then
|
||||
data.disabled = nil
|
||||
end
|
||||
end
|
||||
|
||||
function awards.disable(name)
|
||||
local data = awards.player(name)
|
||||
if data then
|
||||
data.disabled = true
|
||||
end
|
||||
end
|
||||
|
||||
function awards.clear_player(name)
|
||||
awards.players[name] = nil
|
||||
end
|
||||
|
||||
-- This function is called whenever a target condition is met.
|
||||
-- It checks if a player already has that achievement, and if they do not,
|
||||
-- it gives it to them
|
||||
----------------------------------------------
|
||||
--awards.give_achievement(name, award)
|
||||
--awards.unlock(name, award)
|
||||
-- name - the name of the player
|
||||
-- award - the name of the award to give
|
||||
function awards.unlock(name, award)
|
||||
@ -107,6 +125,9 @@ function awards.unlock(name, award)
|
||||
if not awdef then
|
||||
return
|
||||
end
|
||||
if data.disabled then
|
||||
return
|
||||
end
|
||||
awards.tbv(data,"unlocked")
|
||||
|
||||
-- Don't give the achievement if it has already been given
|
||||
@ -225,10 +246,15 @@ awards.give_achievement = awards.unlock
|
||||
end
|
||||
})]]--
|
||||
|
||||
function awards.showto(name, to, sid, text)
|
||||
function awards.show_to(name, to, sid, text)
|
||||
if name == "" or name == nil then
|
||||
name = to
|
||||
end
|
||||
if name == to and awards.player(to).disabled then
|
||||
minetest.chat_send_player("You've disabled awards. Type /awards" ..
|
||||
" enable to reenable")
|
||||
return
|
||||
end
|
||||
if text then
|
||||
if not awards.players[name] or not awards.players[name].unlocked then
|
||||
minetest.chat_send_player(to, "You have not unlocked any awards")
|
||||
@ -320,9 +346,10 @@ function awards.showto(name, to, sid, text)
|
||||
minetest.show_formspec(to,"awards:awards",formspec)
|
||||
end
|
||||
end
|
||||
awards.showto = awards.show_to
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname~="awards:awards" then
|
||||
if formname ~= "awards:awards" then
|
||||
return false
|
||||
end
|
||||
if fields.quit then
|
||||
@ -332,7 +359,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.awards then
|
||||
local event = minetest.explode_textlist_event(fields.awards)
|
||||
if event.type == "CHG" then
|
||||
awards.showto(name,name,event.index,false)
|
||||
awards.show_to(name, name, event.index, false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -14,20 +14,25 @@
|
||||
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
--
|
||||
|
||||
minetest.register_chatcommand("list_awards", {
|
||||
params = "obsolete",
|
||||
description = "list_awards: obsolete. Use /awards",
|
||||
func = function(name, param)
|
||||
minetest.chat_send_player(name, "This command has been made obsolete. Use /awards instead.")
|
||||
awards.showto(name, name, nil, false)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("awards", {
|
||||
params = "",
|
||||
description = "awards: list awards",
|
||||
func = function(name, param)
|
||||
awards.showto(name, name, nil, false)
|
||||
if param == "clear" then
|
||||
awards.clear_player(name)
|
||||
minetest.chat_send_player(name, "All your awards and statistics " ..
|
||||
" have been cleared. You can now start again.")
|
||||
elseif param == "disable" then
|
||||
awards.disable(name)
|
||||
minetest.chat_send_player(name, "You have disabled awards. (only affects you)")
|
||||
elseif param == "enable" then
|
||||
awards.enable(name)
|
||||
minetest.chat_send_player(name, "You have enabled awards. (only affects you)")
|
||||
elseif param == "c" then
|
||||
awards.show_to(name, name, nil, true)
|
||||
else
|
||||
awards.show_to(name, name, nil, false)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
@ -35,7 +40,9 @@ minetest.register_chatcommand("cawards", {
|
||||
params = "",
|
||||
description = "awards: list awards in chat",
|
||||
func = function(name, param)
|
||||
awards.showto(name, name, nil, true)
|
||||
awards.show_to(name, name, nil, true)
|
||||
minetest.chat_send_player(name, "/cawards has been depreciated," ..
|
||||
" use /awards c instead")
|
||||
end
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user