blob: 3971c216205d0d02818864b60f2e7b8855387af2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
-- AWARDS
-- by Rubenwardy, CC-BY-SA
-------------------------------------------------------
-- this is the trigger handler file for the awards mod
-------------------------------------------------------
-- Function for Triggers
awards.onDig={}
awards.onTick={}
-- Player functions
-- Trigger Handles
minetest.register_on_dignode(function(pos, oldnode, digger)
local nodedug = string.split(oldnode.name, ":")
local mod=nodedug[1]
local item=nodedug[2]
local playern = digger:get_player_name()
if (playern~=nil and nodedug~=nil and mod~=nil and item~=nil) then
--check the player's directory
if not player_data[playern] then
player_data[playern]={}
player_data[playern]['count']={}
player_data[playern]['count']['default']={}
player_data[playern]['count']['default']['dirt']=0
player_data[playern]['name']=playern
end
--check player.count.mod
if not player_data[playern]['count'][mod] then
player_data[playern]['count'][mod]={}
end
--check player.count.mod.item
if not player_data[playern]['count'][mod][item] then
player_data[playern]['count'][mod][item]=0
end
player_data[playern]['count'][mod][item]=player_data[playern]['count'][mod][item]+1
print(" - "..mod..":"..item.." 's count is now "..(player_data[playern]['count'][mod][item]))
-- Roll through the onDig functions
local player=digger
local data=player_data[playern]
for i=1,# awards.onDig do
local res=awards.onDig[i](player,data)
if not data['unlocked'] then
data['unlocked']={}
end
if res~=nil and (not data['unlocked'][res] or data['unlocked'][res]~=res) then
data['unlocked'][res]=res
minetest.chat_send_player(playern, "Achievement Unlocked: "..res)
end
end
end
end)
minetest.register_on_newplayer(function(player)
--Player data root
player_data[player:get_player_name()]={}
player_data[player:get_player_name()]['name']=player:get_player_name()
--The player counter
player_data[player:get_player_name()]['count']={}
--Table to contain achievement records
player_data[player:get_player_name()]['unlocked']={}
end)
|