diff options
author | Rubenwardy <anjayward@gmail.com> | 2013-02-22 20:38:01 +0000 |
---|---|---|
committer | Rubenwardy <anjayward@gmail.com> | 2013-02-22 20:38:01 +0000 |
commit | 6a968c87c51a143f5d09da9991db25b6b0673af0 (patch) | |
tree | eeba303400536ffe6d371203e197eed40e6147f8 /triggers.lua | |
parent | aef2e2ae9131718ddc2033380179b5a719a18c2a (diff) |
onPlace and award description
Diffstat (limited to 'triggers.lua')
-rw-r--r-- | triggers.lua | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/triggers.lua b/triggers.lua index 5f4b3b3..2ce81de 100644 --- a/triggers.lua +++ b/triggers.lua @@ -6,6 +6,7 @@ -- Function for Triggers awards.onDig={} +awards.onPlace={} awards.onTick={} -- Player functions @@ -24,8 +25,6 @@ minetest.register_on_dignode(function(pos, oldnode, digger) 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 @@ -57,13 +56,60 @@ minetest.register_on_dignode(function(pos, oldnode, digger) end end) +minetest.register_on_placenode(function(pos, newnode, placer) + local nodedug = string.split(newnode.name, ":") + + local mod=nodedug[1] + local item=nodedug[2] + + local playern = placer: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]['place']={} + player_data[playern]['name']=playern + end + + --check player.count.mod + if not player_data[playern]['place'][mod] then + player_data[playern]['place'][mod]={} + end + + --check player.count.mod.item + if not player_data[playern]['place'][mod][item] then + player_data[playern]['place'][mod][item]=0 + end + + player_data[playern]['place'][mod][item]=player_data[playern]['place'][mod][item]+1 + + print(" - "..mod..":"..item.." 's place is now "..(player_data[playern]['place'][mod][item])) + + -- Roll through the onDig functions + local player=placer + local data=player_data[playern] + + for i=1,# awards.onPlace do + local res=awards.onPlace[i](player,data) + + if res~=nil then + awards.give_achievement(playern,res) + end + end + end +end) + minetest.register_on_newplayer(function(player) + minetest.chat_send_player(player:get_player_name(),"[Awards] Registering you now...") + --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']={} + player_data[player:get_player_name()]['place']={} --Table to contain achievement records player_data[player:get_player_name()]['unlocked']={} |