1
0
mirror of https://gitlab.com/rubenwardy/awards.git synced 2024-11-14 06:30:28 +01:00
awards/triggers.lua

53 lines
1.6 KiB
Lua
Raw Normal View History

2013-02-22 18:53:42 +01:00
-- 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)