summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
authorRubenwardy <anjayward@gmail.com>2013-11-06 18:38:55 +0000
committerRubenwardy <anjayward@gmail.com>2013-11-06 18:38:55 +0000
commit6405b26d65a6289ada84fa21a604f1111ab8b86d (patch)
treeb2d9b50c503443d108d1aed2a85fa890bef0389b /api.lua
parent773f7993203ee0d953bf019fd5e0f818e7008241 (diff)
Move playerdata table around
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/api.lua b/api.lua
index bc975ca..94756ff 100644
--- a/api.lua
+++ b/api.lua
@@ -8,7 +8,7 @@
function save_playerD()
local file = io.open(minetest.get_worldpath().."/awards.txt", "w")
if file then
- file:write(minetest.serialize(player_data))
+ file:write(minetest.serialize(awards.players))
file:close()
end
end
@@ -26,7 +26,10 @@ end
-- The global award namespace
awards={}
-player_data=load_playerD()
+awards.players=load_playerD()
+function awards.player(name)
+ return awards.players[player]
+end
-- A table of award definitions
awards.def={}
@@ -114,7 +117,7 @@ end
-- award - the name of the award to give
function awards.give_achievement(name,award)
-- Access Player Data
- local data=player_data[name]
+ local data=awards.players[name]
-- Perform checks
if not data then
@@ -181,13 +184,13 @@ minetest.register_chatcommand("list_awards", {
params = "",
description = "list_awards: list your awards",
func = function(name, param)
- if not player_data[name] then
+ if not awards.players[name] then
minetest.chat_send_player(name, "Unable to find your award listings!")
end
minetest.chat_send_player(name, name.."'s awards:")
- for _, str in pairs(player_data[name].unlocked) do
+ for _, str in pairs(awards.players[name].unlocked) do
minetest.chat_send_player(name, str);
end
end,