mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 18:41:09 +01:00
Make mcl_item_entity
API public
This commit is contained in:
parent
3bb86fd436
commit
96e83e866c
1 changed files with 10 additions and 7 deletions
|
@ -22,10 +22,9 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
pool[player:get_player_name()] = nil
|
pool[player:get_player_name()] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
local has_awards = minetest.get_modpath("awards")
|
local has_awards = minetest.get_modpath("awards")
|
||||||
|
|
||||||
local mcl_item_entity = {}
|
mcl_item_entity = {}
|
||||||
|
|
||||||
--basic settings
|
--basic settings
|
||||||
local item_drop_settings = {} --settings table
|
local item_drop_settings = {} --settings table
|
||||||
|
@ -46,19 +45,23 @@ local function get_gravity()
|
||||||
return tonumber(minetest.settings:get("movement_gravity")) or 9.81
|
return tonumber(minetest.settings:get("movement_gravity")) or 9.81
|
||||||
end
|
end
|
||||||
|
|
||||||
local registered_pickup_achievement = {}
|
mcl_item_entity.registered_pickup_achievement = {}
|
||||||
|
|
||||||
--TODO: remove limitation of 1 award per itemname
|
---Register an achievement that will be unlocked on pickup.
|
||||||
|
---
|
||||||
|
---TODO: remove limitation of 1 award per itemname
|
||||||
|
---@param itemname string
|
||||||
|
---@param award string
|
||||||
function mcl_item_entity.register_pickup_achievement(itemname, award)
|
function mcl_item_entity.register_pickup_achievement(itemname, award)
|
||||||
if not has_awards then
|
if not has_awards then
|
||||||
minetest.log("warning",
|
minetest.log("warning",
|
||||||
"[mcl_item_entity] Trying to register pickup achievement [" .. award .. "] for [" ..
|
"[mcl_item_entity] Trying to register pickup achievement [" .. award .. "] for [" ..
|
||||||
itemname .. "] while awards missing")
|
itemname .. "] while awards missing")
|
||||||
elseif registered_pickup_achievement[itemname] then
|
elseif mcl_item_entity.registered_pickup_achievement[itemname] then
|
||||||
minetest.log("error",
|
minetest.log("error",
|
||||||
"[mcl_item_entity] Trying to register already existing pickup achievement [" .. award .. "] for [" .. itemname .. "]")
|
"[mcl_item_entity] Trying to register already existing pickup achievement [" .. award .. "] for [" .. itemname .. "]")
|
||||||
else
|
else
|
||||||
registered_pickup_achievement[itemname] = award
|
mcl_item_entity.registered_pickup_achievement[itemname] = award
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -77,7 +80,7 @@ local function check_pickup_achievements(object, player)
|
||||||
if has_awards then
|
if has_awards then
|
||||||
local itemname = ItemStack(object:get_luaentity().itemstring):get_name()
|
local itemname = ItemStack(object:get_luaentity().itemstring):get_name()
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
for name, award in pairs(registered_pickup_achievement) do
|
for name, award in pairs(mcl_item_entity.registered_pickup_achievement) do
|
||||||
if itemname == name or minetest.get_item_group(itemname, name) ~= 0 then
|
if itemname == name or minetest.get_item_group(itemname, name) ~= 0 then
|
||||||
awards.unlock(playername, award)
|
awards.unlock(playername, award)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue