summaryrefslogtreecommitdiff
path: root/triggers.lua
diff options
context:
space:
mode:
authorRubenwardy <anjayward@gmail.com>2013-02-22 17:53:42 +0000
committerRubenwardy <anjayward@gmail.com>2013-02-22 17:53:42 +0000
commitbc2b7902ed5f2a192303277f242b3cca065b0623 (patch)
tree699bd6d80f9f76f1acc941a3bfc2c6b7495d42c9 /triggers.lua
Initial Commit
Diffstat (limited to 'triggers.lua')
-rw-r--r--triggers.lua53
1 files changed, 53 insertions, 0 deletions
diff --git a/triggers.lua b/triggers.lua
new file mode 100644
index 0000000..2c9492a
--- /dev/null
+++ b/triggers.lua
@@ -0,0 +1,53 @@
+-- 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[0]
+ local item=nodedug[1]
+
+ local player = digger:get_player_name()
+
+ print("Awards [Event] - "..player.." has dug a node")
+
+ if (player~=nil and nodedug~=nil and mod~=nil and item~=nil) then
+ if not player_data[player] then
+ player_data[player]={}
+ player_data[player]['count']={}
+ player_data[player]['count']['default']={}
+ player_data[player]['count']['default']['dirt']=0
+ player_data[player]['name']=player
+ end
+
+ if not player_data[player]['count'][mod] then
+ player_data[player]['count'][mod]={}
+ end
+
+ if not player_data[player]['count'][mod][item] then
+ player_data[player]['count'][mod][item]=0
+ end
+
+ player_data[player]['count'][mod][item]=player_data[player]['count'][mod][item]+1
+ else
+ print(player.."'s dig event has been skipped")
+ end
+end)
+
+minetest.register_on_newplayer(function(player)
+ player_data[player:get_player_name()]={}
+ player_data[player:get_player_name()]['count']={}
+ player_data[player:get_player_name()]['count']['default']={}
+ player_data[player:get_player_name()]['count']['default']['dirt']=0
+ player_data[player:get_player_name()]['name']=player:get_player_name()
+end) \ No newline at end of file