Readd triggers

This commit is contained in:
rubenwardy 2018-04-04 18:35:28 +01:00
parent 28c59340ea
commit eaab883e71

View File

@ -21,6 +21,7 @@ awards.register_trigger("death", {
}) })
minetest.register_on_dieplayer(awards.notify_death) minetest.register_on_dieplayer(awards.notify_death)
awards.register_trigger("chat", { awards.register_trigger("chat", {
type = "counted", type = "counted",
progress = "@1/@2 chat messages", progress = "@1/@2 chat messages",
@ -35,6 +36,7 @@ minetest.register_on_chat_message(function(name, message)
awards.notify_chat(player) awards.notify_chat(player)
end) end)
awards.register_trigger("join", { awards.register_trigger("join", {
type = "counted", type = "counted",
progress = "@1/@2 joins", progress = "@1/@2 joins",
@ -52,116 +54,72 @@ awards.register_trigger("dig", {
return minetest.registered_aliases[def.trigger.node] or def.trigger.node return minetest.registered_aliases[def.trigger.node] or def.trigger.node
end end
}) })
minetest.register_on_dignode(function(pos, node, player)
minetest.register_on_dignode(function(pos, oldnode, player) if not player or not pos or not node then
if not player or not pos or not oldnode then
return return
end end
local node_name = oldnode.name local node_name = node.name
node_name = minetest.registered_aliases[node_name] or node_name node_name = minetest.registered_aliases[node_name] or node_name
awards.notify_dig(player, node_name) awards.notify_dig(player, node_name)
end) end)
--
-- awards.register_trigger("place", {
-- type = "counted_key",
-- progress = "@1/@2 placed",
-- auto_description = { "Place: @2", "Place: @1×@2" },
-- auto_description_total = { "Place @1 block.", "Place @1 blocks." },
-- get_key = function(self, def)
-- return minetest.registered_aliases[def.trigger.node] or def.trigger.node
-- end
-- })
--
-- awards.register_trigger("craft", {
-- type = "counted_key",
-- progress = "@1/@2 crafted",
-- auto_description = { "Craft: @2", "Craft: @1×@2" },
-- auto_description_total = { "Craft @1 item", "Craft @1 items." },
-- get_key = function(self, def)
-- return minetest.registered_aliases[def.trigger.item] or def.trigger.item
-- end
-- })
-- Trigger Handles
-- awards.register_trigger("place", {
-- minetest.register_on_placenode(function(pos, node, digger) type = "counted_key",
-- if not digger or not pos or not node or not digger:get_player_name() or digger:get_player_name()=="" then progress = "@1/@2 placed",
-- return auto_description = { "Place: @2", "Place: @1×@2" },
-- end auto_description_total = { "Place @1 block.", "Place @1 blocks." },
-- local data = awards.players[digger:get_player_name()] get_key = function(self, def)
-- if not awards.increment_item_counter(data, "place", node.name) then return minetest.registered_aliases[def.trigger.node] or def.trigger.node
-- return end
-- end })
-- minetest.register_on_placenode(function(pos, node, player)
-- awards.run_trigger_callbacks(digger, data, "place", function(entry) if not player or not pos or not node then
-- if entry.target then return
-- if entry.node then end
-- local tnodedug = string.split(entry.node, ":")
-- local tmod = tnodedug[1] local node_name = node.name
-- local titem = tnodedug[2] node_name = minetest.registered_aliases[node_name] or node_name
-- if not (not tmod or not titem or not data.place[tmod] or awards.notify_place(player, node_name)
-- not data.place[tmod][titem]) and end)
-- data.place[tmod][titem] > entry.target-1 then
-- return entry.award
-- end awards.register_trigger("craft", {
-- elseif awards.get_total_item_count(data, "place") > entry.target-1 then type = "counted_key",
-- return entry.award progress = "@1/@2 crafted",
-- end auto_description = { "Craft: @2", "Craft: @1×@2" },
-- end auto_description_total = { "Craft @1 item", "Craft @1 items." },
-- end) get_key = function(self, def)
-- end) return minetest.registered_aliases[def.trigger.item] or def.trigger.item
-- end
-- minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing) })
-- if not user or not itemstack or not user:get_player_name() or user:get_player_name()=="" then minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
-- return if not player or itemstack:empty() then
-- end return
-- local data = awards.players[user:get_player_name()] end
-- if not awards.increment_item_counter(data, "eat", itemstack:get_name()) then
-- return local itemname = itemstack:get_name()
-- end itemname = minetest.registered_aliases[itemname] or itemname
-- awards.run_trigger_callbacks(user, data, "eat", function(entry) awards.notify_craft(player, itemname, itemstack:get_count())
-- if entry.target then end)
-- if entry.item then
-- local titemstring = string.split(entry.item, ":")
-- local tmod = titemstring[1] awards.register_trigger("eat", {
-- local titem = titemstring[2] type = "counted_key",
-- if not (not tmod or not titem or not data.eat[tmod] or progress = "@1/@2 eaten",
-- not data.eat[tmod][titem]) and auto_description = { "Eat @2", "Eat @1×@2" },
-- data.eat[tmod][titem] > entry.target-1 then auto_description_total = { "Eat @1 item", "Eat @1 items." },
-- return entry.award get_key = function(self, def)
-- end return minetest.registered_aliases[def.trigger.item] or def.trigger.item
-- elseif awards.get_total_item_count(data, "eat") > entry.target-1 then end
-- return entry.award })
-- end minetest.register_on_item_eat(function(_, _, itemstack, player, _)
-- end if not player or itemstack:empty() then
-- end) return
-- end) end
--
-- minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) local itemname = itemstack:get_name()
-- if not player or not itemstack then itemname = minetest.registered_aliases[itemname] or itemname
-- return awards.notify_craft(player, itemname, itemstack:get_count())
-- end end)
--
-- local data = awards.players[player:get_player_name()]
-- if not awards.increment_item_counter(data, "craft", itemstack:get_name(), itemstack:get_count()) then
-- return
-- end
--
-- awards.run_trigger_callbacks(player, data, "craft", function(entry)
-- if entry.target then
-- if entry.item then
-- local titemcrafted = string.split(entry.item, ":")
-- local tmod = titemcrafted[1]
-- local titem = titemcrafted[2]
-- if not (not tmod or not titem or not data.craft[tmod] or
-- not data.craft[tmod][titem]) and
-- data.craft[tmod][titem] > entry.target-1 then
-- return entry.award
-- end
-- elseif awards.get_total_item_count(data, "craft") > entry.target-1 then
-- return entry.award
-- end
-- end
-- end)
-- end)