mirror of
https://gitlab.com/rubenwardy/awards.git
synced 2024-11-26 09:13:55 +01:00
Add eat trigger, extend existing triggers, add 9 awards (#35)
* Add eat trigger and 2 new awards * Add mushroom eating awards * Add support for counting any eat/dig/craft/place * Update readme * Add 4 builder awards * Update German locale * Update dependencies * Fix mistake in German translation * Revert removal of background
This commit is contained in:
parent
ab7206e150
commit
38c504e938
16
api.lua
16
api.lua
@ -115,6 +115,22 @@ function awards.get_item_count(data, field, itemname)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function awards.get_total_item_count(data, field)
|
||||||
|
local i = 0
|
||||||
|
if data and field then
|
||||||
|
awards.assertPlayer(data)
|
||||||
|
awards.tbv(data, field)
|
||||||
|
for mod,_ in pairs(data[field]) do
|
||||||
|
awards.tbv(data[field], mod)
|
||||||
|
for item,_ in pairs(data[field][mod]) do
|
||||||
|
awards.tbv(data[field][mod], item, 0)
|
||||||
|
i = i + data[field][mod][item]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
|
||||||
function awards.register_on_unlock(func)
|
function awards.register_on_unlock(func)
|
||||||
table.insert(awards.on_unlock, func)
|
table.insert(awards.on_unlock, func)
|
||||||
end
|
end
|
||||||
|
@ -27,6 +27,7 @@ function awards.assertPlayer(playern)
|
|||||||
awards.tbv(awards.players[playern], "place")
|
awards.tbv(awards.players[playern], "place")
|
||||||
awards.tbv(awards.players[playern], "count")
|
awards.tbv(awards.players[playern], "count")
|
||||||
awards.tbv(awards.players[playern], "craft")
|
awards.tbv(awards.players[playern], "craft")
|
||||||
|
awards.tbv(awards.players[playern], "eat")
|
||||||
awards.tbv(awards.players[playern], "deaths", 0)
|
awards.tbv(awards.players[playern], "deaths", 0)
|
||||||
awards.tbv(awards.players[playern], "joins", 0)
|
awards.tbv(awards.players[playern], "joins", 0)
|
||||||
awards.tbv(awards.players[playern], "chats", 0)
|
awards.tbv(awards.players[playern], "chats", 0)
|
||||||
|
@ -10,3 +10,4 @@ wool?
|
|||||||
vessels?
|
vessels?
|
||||||
moreblocks?
|
moreblocks?
|
||||||
fire?
|
fire?
|
||||||
|
flowers?
|
||||||
|
105
init.lua
105
init.lua
@ -684,6 +684,17 @@ if minetest.get_modpath("default") then
|
|||||||
target = 40
|
target = 40
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
awards.register_achievement("award_apples", {
|
||||||
|
title = S("Yummy!"),
|
||||||
|
description = S("Eat 80 apples."),
|
||||||
|
icon = "default_apple.png",
|
||||||
|
trigger = {
|
||||||
|
type = "eat",
|
||||||
|
item = "default:apple",
|
||||||
|
target = 80
|
||||||
|
}
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("vessels") then
|
if minetest.get_modpath("vessels") then
|
||||||
@ -743,6 +754,17 @@ if minetest.get_modpath("farming") then
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
awards.register_achievement("award_bread", {
|
||||||
|
title = S("Baker"),
|
||||||
|
description = S("Eat 10 loaves of bread."),
|
||||||
|
icon = "farming_bread.png",
|
||||||
|
trigger = {
|
||||||
|
type = "eat",
|
||||||
|
item = "farming:bread",
|
||||||
|
target = 10
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("wool") and minetest.get_modpath("farming") then
|
if minetest.get_modpath("wool") and minetest.get_modpath("farming") then
|
||||||
@ -829,3 +851,86 @@ if minetest.get_modpath("dye") then
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if minetest.get_modpath("flowers") then
|
||||||
|
awards.register_achievement("awards_brown_mushroom1", {
|
||||||
|
title = S("Tasty Mushrooms"),
|
||||||
|
description = S("Eat 3 brown mushrooms."),
|
||||||
|
icon = "flowers_mushroom_brown.png^awards_level1.png",
|
||||||
|
trigger = {
|
||||||
|
type = "eat",
|
||||||
|
item= "flowers:mushroom_brown",
|
||||||
|
target = 3,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
awards.register_achievement("awards_brown_mushroom2", {
|
||||||
|
title = S("Mushroom Lover"),
|
||||||
|
description = S("Eat 33 brown mushrooms."),
|
||||||
|
icon = "flowers_mushroom_brown.png^awards_level2.png",
|
||||||
|
trigger = {
|
||||||
|
type = "eat",
|
||||||
|
item= "flowers:mushroom_brown",
|
||||||
|
target = 33,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
awards.register_achievement("awards_brown_mushroom3", {
|
||||||
|
title = S("Underground Mushroom Farmer"),
|
||||||
|
description = S("Eat 333 brown mushrooms."),
|
||||||
|
icon = "flowers_mushroom_brown.png^awards_level3.png",
|
||||||
|
trigger = {
|
||||||
|
type = "eat",
|
||||||
|
item= "flowers:mushroom_brown",
|
||||||
|
target = 333,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- This ensures the following code is executed after all items have been registered
|
||||||
|
minetest.after(0, function()
|
||||||
|
-- Check whether there is at least one node which can be built by the player
|
||||||
|
local building_is_possible = false
|
||||||
|
for _, def in pairs(minetest.registered_nodes) do
|
||||||
|
if (def.description and def.pointable ~= false and not def.groups.not_in_creative_inventory) then
|
||||||
|
building_is_possible = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- The following awards require at least one node which can be built
|
||||||
|
if not building_is_possible then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
awards.register_achievement("awards_builder1", {
|
||||||
|
title = S("Builder"),
|
||||||
|
icon = "awards_house.png^awards_level1.png",
|
||||||
|
trigger = {
|
||||||
|
type = "place",
|
||||||
|
target = 1000,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
awards.register_achievement("awards_builder2", {
|
||||||
|
title = S("Constructor"),
|
||||||
|
icon = "awards_house.png^awards_level2.png",
|
||||||
|
trigger = {
|
||||||
|
type = "place",
|
||||||
|
target = 5000,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
awards.register_achievement("awards_builder3", {
|
||||||
|
title = S("Architect"),
|
||||||
|
icon = "awards_house.png^awards_level3.png",
|
||||||
|
trigger = {
|
||||||
|
type = "place",
|
||||||
|
target = 10000,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
awards.register_achievement("awards_builder4", {
|
||||||
|
title = S("Master Architect"),
|
||||||
|
icon = "awards_house.png^awards_level4.png",
|
||||||
|
trigger = {
|
||||||
|
type = "place",
|
||||||
|
target = 25000,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
@ -175,3 +175,24 @@ Join the game %d times. = Treten Sie dem Spiel %d mal bei.
|
|||||||
Show details of an achievement = Details einer Auszeichnung anzeigen
|
Show details of an achievement = Details einer Auszeichnung anzeigen
|
||||||
OK = OK
|
OK = OK
|
||||||
Error: No awards available. = Fehler: Keine Auszeichnungen vorhanden.
|
Error: No awards available. = Fehler: Keine Auszeichnungen vorhanden.
|
||||||
|
Eat: %d×%s = Essen Sie: %d×%s
|
||||||
|
Eat: %s = Essen Sie: %s
|
||||||
|
%d/%d eaten = %d/%d gegessen
|
||||||
|
Yummy! = Lecker!
|
||||||
|
Baker = Bäcker
|
||||||
|
Eat 10 loaves of bread. = Essen Sie 10 Brote.
|
||||||
|
Eat 80 apples. = Essen Sie 80 Äpfel.
|
||||||
|
Tasty Mushrooms = Leckere Pilze
|
||||||
|
Mushroom Lover = Pilzfreund
|
||||||
|
Underground Mushroom Farmer = Unterirdischer Pilzbauer
|
||||||
|
Eat 3 brown mushrooms. = Essen Sie 3 braune Pilze.
|
||||||
|
Eat 33 brown mushrooms. = Essen Sie 33 braune Pilze.
|
||||||
|
Eat 333 brown mushrooms. = Essen Sie 333 braune Pilze.
|
||||||
|
Builder = Bauarbeiter
|
||||||
|
Constructor = Konstrukteur
|
||||||
|
Architect = Architekt
|
||||||
|
Master Architect = Meisterarchitekt
|
||||||
|
Place %d block(s). = Platzieren Sie %d Blöcke.
|
||||||
|
Dig %d block(s). = Bauen Sie %d Blöcke ab.
|
||||||
|
Eat %d item(s). = Essen Sie %d Dinge.
|
||||||
|
Craft %d item(s). = Fertigen Sie %d Gegenstände.
|
||||||
|
@ -177,3 +177,20 @@ You’re a copper =
|
|||||||
[c|clear|disable|enable] =
|
[c|clear|disable|enable] =
|
||||||
OK =
|
OK =
|
||||||
Error: No awards available. =
|
Error: No awards available. =
|
||||||
|
Eat: %d×%s =
|
||||||
|
Eat: %s =
|
||||||
|
%d/%d eaten =
|
||||||
|
Place %d block(s). =
|
||||||
|
Dig %d block(s). =
|
||||||
|
Eat %d item(s). =
|
||||||
|
Craft %d item(s). =
|
||||||
|
Yummy! =
|
||||||
|
Baker =
|
||||||
|
Eat 10 loaves of bread. =
|
||||||
|
Eat 80 apples. =
|
||||||
|
Tasty Mushrooms =
|
||||||
|
Mushroom Lover =
|
||||||
|
Underground Mushroom Farmer =
|
||||||
|
Eat 3 brown mushrooms. =
|
||||||
|
Eat 33 brown mushrooms. =
|
||||||
|
Eat 333 brown mushrooms. =
|
||||||
|
31
readme.md
31
readme.md
@ -18,10 +18,19 @@ old fork in Carbone, under same license.
|
|||||||
* image [optional] - texture name, eg: award_one.png
|
* image [optional] - texture name, eg: award_one.png
|
||||||
* background [optional] - texture name, eg: award_one.png
|
* background [optional] - texture name, eg: award_one.png
|
||||||
* trigger [optional] [table]
|
* trigger [optional] [table]
|
||||||
* type - "dig", "place", "craft", "death", "chat" or "join"
|
* type - "dig", "place", "craft", "death", "chat", "join" or "eat"
|
||||||
* (for dig/place type) node - the nodes name
|
* dig type: Dig a node.
|
||||||
* (for craft type) item - the items name
|
* node: the dug node type. If nil, all dug nodes are counted
|
||||||
* (for all types) target - how many to dig / place
|
* place type: Place a node.
|
||||||
|
* node: the placed node type. If nil, all placed nodes are counted
|
||||||
|
* eat type: Eat an item.
|
||||||
|
* item: the eaten item type. If nil, all eaten items are counted
|
||||||
|
* craft type: Craft something.
|
||||||
|
* item: the crafted item type. If nil, all crafted items are counted
|
||||||
|
* death type: Die.
|
||||||
|
* chat type: Write a chat message.
|
||||||
|
* join type: Join the server.
|
||||||
|
* (for all types) target - how many times to dig/place/craft/etc.
|
||||||
* See Triggers
|
* See Triggers
|
||||||
* secret [optional] - if true, then player needs to unlock to find out what it is.
|
* secret [optional] - if true, then player needs to unlock to find out what it is.
|
||||||
* on_unlock [optional] - func(name, def)
|
* on_unlock [optional] - func(name, def)
|
||||||
@ -101,6 +110,14 @@ Callbacks (register a function to be run)
|
|||||||
target = 100
|
target = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### eat
|
||||||
|
|
||||||
|
trigger = {
|
||||||
|
type = "eat",
|
||||||
|
item = "default:apple",
|
||||||
|
target = 100
|
||||||
|
}
|
||||||
|
|
||||||
## Callbacks relating to triggers
|
## Callbacks relating to triggers
|
||||||
|
|
||||||
* awards.register_on_dig(func(player, data))
|
* awards.register_on_dig(func(player, data))
|
||||||
@ -109,6 +126,9 @@ Callbacks (register a function to be run)
|
|||||||
* awards.register_on_place(func(player, data))
|
* awards.register_on_place(func(player, data))
|
||||||
* data is player data (see below)
|
* data is player data (see below)
|
||||||
* return award name or null
|
* return award name or null
|
||||||
|
* awards.register_on_eat(func(player, data))
|
||||||
|
* data is player data (see below)
|
||||||
|
* return award name or null
|
||||||
* awards.register_on_death(func(player, data))
|
* awards.register_on_death(func(player, data))
|
||||||
* data is player data (see below)
|
* data is player data (see below)
|
||||||
* return award name or null
|
* return award name or null
|
||||||
@ -134,6 +154,9 @@ A list of data referenced/hashed by the player's name.
|
|||||||
* craft [table] - craft counter
|
* craft [table] - craft counter
|
||||||
* modname [table]
|
* modname [table]
|
||||||
* itemname [int]
|
* itemname [int]
|
||||||
|
* eat [table] - eat counter
|
||||||
|
* modname [table]
|
||||||
|
* itemname [int]
|
||||||
* deaths
|
* deaths
|
||||||
* chats
|
* chats
|
||||||
* joins
|
* joins
|
||||||
|
BIN
textures/awards_house.png
Normal file
BIN
textures/awards_house.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 591 B |
114
triggers.lua
114
triggers.lua
@ -29,23 +29,31 @@ awards.register_trigger("dig", function(def)
|
|||||||
}
|
}
|
||||||
table.insert(awards.on.dig, tmp)
|
table.insert(awards.on.dig, tmp)
|
||||||
def.getProgress = function(self, data)
|
def.getProgress = function(self, data)
|
||||||
local itemcount = awards.get_item_count(data, "count", tmp.node) or 0
|
local itemcount
|
||||||
|
if tmp.node then
|
||||||
|
itemcount = awards.get_item_count(data, "count", tmp.node) or 0
|
||||||
|
else
|
||||||
|
itemcount = awards.get_total_item_count(data, "count")
|
||||||
|
end
|
||||||
return {
|
return {
|
||||||
perc = itemcount / tmp.target,
|
perc = itemcount / tmp.target,
|
||||||
label = string.format(S("%d/%d dug"), itemcount, tmp.target)
|
label = string.format(S("%d/%d dug"), itemcount, tmp.target)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
def.getDefaultDescription = function(self)
|
def.getDefaultDescription = function(self)
|
||||||
|
if self.trigger.node then
|
||||||
local nname = minetest.registered_nodes[self.trigger.node].description
|
local nname = minetest.registered_nodes[self.trigger.node].description
|
||||||
if nname == nil then
|
if nname == nil then
|
||||||
nname = self.trigger.node
|
nname = self.trigger.node
|
||||||
end
|
end
|
||||||
local ddesc
|
|
||||||
if self.trigger.target ~= 1 then
|
if self.trigger.target ~= 1 then
|
||||||
return string.format(S("Mine blocks: %d×%s"), self.trigger.target, nname)
|
return string.format(S("Mine blocks: %d×%s"), self.trigger.target, nname)
|
||||||
else
|
else
|
||||||
return string.format(S("Mine a block: %s"), nname)
|
return string.format(S("Mine a block: %s"), nname)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
return string.format(S("Mine %d block(s)."), self.trigger.target)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -57,13 +65,19 @@ awards.register_trigger("place", function(def)
|
|||||||
}
|
}
|
||||||
table.insert(awards.on.place, tmp)
|
table.insert(awards.on.place, tmp)
|
||||||
def.getProgress = function(self, data)
|
def.getProgress = function(self, data)
|
||||||
local itemcount = awards.get_item_count(data, "place", tmp.node) or 0
|
local itemcount
|
||||||
|
if tmp.node then
|
||||||
|
itemcount = awards.get_item_count(data, "place", tmp.node) or 0
|
||||||
|
else
|
||||||
|
itemcount = awards.get_total_item_count(data, "place")
|
||||||
|
end
|
||||||
return {
|
return {
|
||||||
perc = itemcount / tmp.target,
|
perc = itemcount / tmp.target,
|
||||||
label = string.format(S("%d/%d placed"), itemcount, tmp.target)
|
label = string.format(S("%d/%d placed"), itemcount, tmp.target)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
def.getDefaultDescription = function(self)
|
def.getDefaultDescription = function(self)
|
||||||
|
if self.trigger.node then
|
||||||
local nname = minetest.registered_nodes[self.trigger.node].description
|
local nname = minetest.registered_nodes[self.trigger.node].description
|
||||||
if nname == nil then
|
if nname == nil then
|
||||||
nname = self.trigger.node
|
nname = self.trigger.node
|
||||||
@ -73,6 +87,45 @@ awards.register_trigger("place", function(def)
|
|||||||
else
|
else
|
||||||
return string.format(S("Place a block: %s"), nname)
|
return string.format(S("Place a block: %s"), nname)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
return string.format(S("Place %d block(s)."), self.trigger.target)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
awards.register_trigger("eat", function(def)
|
||||||
|
local tmp = {
|
||||||
|
award = def.name,
|
||||||
|
item = def.trigger.item,
|
||||||
|
target = def.trigger.target,
|
||||||
|
}
|
||||||
|
table.insert(awards.on.eat, tmp)
|
||||||
|
def.getProgress = function(self, data)
|
||||||
|
local itemcount
|
||||||
|
if tmp.item then
|
||||||
|
itemcount = awards.get_item_count(data, "eat", tmp.item) or 0
|
||||||
|
else
|
||||||
|
itemcount = awards.get_total_item_count(data, "eat")
|
||||||
|
end
|
||||||
|
return {
|
||||||
|
perc = itemcount / tmp.target,
|
||||||
|
label = string.format(S("%d/%d eaten"), itemcount, tmp.target)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
def.getDefaultDescription = function(self)
|
||||||
|
if self.trigger.item then
|
||||||
|
local iname = minetest.registered_items[self.trigger.item].description
|
||||||
|
if iname == nil then
|
||||||
|
iname = self.trigger.iode
|
||||||
|
end
|
||||||
|
if self.trigger.target ~= 1 then
|
||||||
|
return string.format(S("Eat: %d×%s"), self.trigger.target, iname)
|
||||||
|
else
|
||||||
|
return string.format(S("Eat: %s"), iname)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return string.format(S("Eat %d item(s)."), self.trigger.target)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -150,13 +203,19 @@ awards.register_trigger("craft", function(def)
|
|||||||
}
|
}
|
||||||
table.insert(awards.on.craft, tmp)
|
table.insert(awards.on.craft, tmp)
|
||||||
def.getProgress = function(self, data)
|
def.getProgress = function(self, data)
|
||||||
local itemcount = awards.get_item_count(data, "craft", tmp.item) or 0
|
local itemcount
|
||||||
|
if tmp.item then
|
||||||
|
itemcount = awards.get_item_count(data, "craft", tmp.item) or 0
|
||||||
|
else
|
||||||
|
itemcount = awards.get_total_item_count(data, "craft")
|
||||||
|
end
|
||||||
return {
|
return {
|
||||||
perc = itemcount / tmp.target,
|
perc = itemcount / tmp.target,
|
||||||
label = string.format(S("%d/%d crafted"), itemcount, tmp.target)
|
label = string.format(S("%d/%d crafted"), itemcount, tmp.target)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
def.getDefaultDescription = function(self)
|
def.getDefaultDescription = function(self)
|
||||||
|
if self.trigger.item then
|
||||||
local iname = minetest.registered_items[self.trigger.item].description
|
local iname = minetest.registered_items[self.trigger.item].description
|
||||||
if iname == nil then
|
if iname == nil then
|
||||||
iname = self.trigger.item
|
iname = self.trigger.item
|
||||||
@ -166,6 +225,9 @@ awards.register_trigger("craft", function(def)
|
|||||||
else
|
else
|
||||||
return string.format(S("Craft: %s"), iname)
|
return string.format(S("Craft: %s"), iname)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
return string.format(S("Craft %d item(s)."), self.trigger.target)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -188,7 +250,8 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
awards.run_trigger_callbacks(digger, data, "dig", function(entry)
|
awards.run_trigger_callbacks(digger, data, "dig", function(entry)
|
||||||
if entry.node and entry.target then
|
if entry.target then
|
||||||
|
if entry.node then
|
||||||
local tnodedug = string.split(entry.node, ":")
|
local tnodedug = string.split(entry.node, ":")
|
||||||
local tmod = tnodedug[1]
|
local tmod = tnodedug[1]
|
||||||
local titem = tnodedug[2]
|
local titem = tnodedug[2]
|
||||||
@ -197,6 +260,9 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
|
|||||||
elseif data.count[tmod][titem] > entry.target-1 then
|
elseif data.count[tmod][titem] > entry.target-1 then
|
||||||
return entry.award
|
return entry.award
|
||||||
end
|
end
|
||||||
|
elseif awards.get_total_item_count(data, "count") > entry.target-1 then
|
||||||
|
return entry.award
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -211,7 +277,8 @@ minetest.register_on_placenode(function(pos, node, digger)
|
|||||||
end
|
end
|
||||||
|
|
||||||
awards.run_trigger_callbacks(digger, data, "place", function(entry)
|
awards.run_trigger_callbacks(digger, data, "place", function(entry)
|
||||||
if entry.node and entry.target then
|
if entry.target then
|
||||||
|
if entry.node then
|
||||||
local tnodedug = string.split(entry.node, ":")
|
local tnodedug = string.split(entry.node, ":")
|
||||||
local tmod = tnodedug[1]
|
local tmod = tnodedug[1]
|
||||||
local titem = tnodedug[2]
|
local titem = tnodedug[2]
|
||||||
@ -220,6 +287,35 @@ minetest.register_on_placenode(function(pos, node, digger)
|
|||||||
elseif data.place[tmod][titem] > entry.target-1 then
|
elseif data.place[tmod][titem] > entry.target-1 then
|
||||||
return entry.award
|
return entry.award
|
||||||
end
|
end
|
||||||
|
elseif awards.get_total_item_count(data, "place") > entry.target-1 then
|
||||||
|
return entry.award
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
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
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local data = awards.players[user:get_player_name()]
|
||||||
|
if not awards.increment_item_counter(data, "eat", itemstack:get_name()) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
awards.run_trigger_callbacks(user, data, "eat", function(entry)
|
||||||
|
if entry.target then
|
||||||
|
if entry.item then
|
||||||
|
local titemstring = string.split(entry.item, ":")
|
||||||
|
local tmod = titemstring[1]
|
||||||
|
local titem = titemstring[2]
|
||||||
|
if not tmod or not titem or not data.eat[tmod] or not data.eat[tmod][titem] then
|
||||||
|
-- table running failed!
|
||||||
|
elseif data.eat[tmod][titem] > entry.target-1 then
|
||||||
|
return entry.award
|
||||||
|
end
|
||||||
|
elseif awards.get_total_item_count(data, "eat") > entry.target-1 then
|
||||||
|
return entry.award
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -235,7 +331,8 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
|
|||||||
end
|
end
|
||||||
|
|
||||||
awards.run_trigger_callbacks(player, data, "craft", function(entry)
|
awards.run_trigger_callbacks(player, data, "craft", function(entry)
|
||||||
if entry.item and entry.target then
|
if entry.target then
|
||||||
|
if entry.item then
|
||||||
local titemcrafted = string.split(entry.item, ":")
|
local titemcrafted = string.split(entry.item, ":")
|
||||||
local tmod = titemcrafted[1]
|
local tmod = titemcrafted[1]
|
||||||
local titem = titemcrafted[2]
|
local titem = titemcrafted[2]
|
||||||
@ -244,6 +341,9 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
|
|||||||
elseif data.craft[tmod][titem] > entry.target-1 then
|
elseif data.craft[tmod][titem] > entry.target-1 then
|
||||||
return entry.award
|
return entry.award
|
||||||
end
|
end
|
||||||
|
elseif awards.get_total_item_count(data, "craft") > entry.target-1 then
|
||||||
|
return entry.award
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user