mirror of
https://github.com/FaceDeer/dfcaverns.git
synced 2024-12-24 18:00:36 +01:00
fix farming achievements, fix spindlestem callbacks on place
This commit is contained in:
parent
d7656c5ace
commit
4a7215f7a7
@ -70,8 +70,8 @@ awards.register_on_unlock(function(player_name, def)
|
||||
test_list(player_name, "dfcaverns_plant_all_upper_trees", unlocked, all_upper_trees)
|
||||
end)
|
||||
|
||||
for achievement, def in pairs(plant_node_achievements) do
|
||||
awards.register_achievement(achievement, {
|
||||
for _, def in pairs(plant_node_achievements) do
|
||||
awards.register_achievement(def.achievement, {
|
||||
title = def.title,
|
||||
description = def.desc,
|
||||
--icon = def.icon,
|
||||
|
@ -7,6 +7,16 @@ local get_spindlestem_cap_type
|
||||
|
||||
-- Copied from subterrane's features.lua
|
||||
-- Figured that was nicer than adding a dependency for just this little bit
|
||||
|
||||
local function copy_pointed_thing(pointed_thing)
|
||||
return {
|
||||
type = pointed_thing.type,
|
||||
above = pointed_thing.above and vector.copy(pointed_thing.above),
|
||||
under = pointed_thing.under and vector.copy(pointed_thing.under),
|
||||
ref = pointed_thing.ref,
|
||||
}
|
||||
end
|
||||
|
||||
local stem_on_place = function(itemstack, placer, pointed_thing)
|
||||
local pt = pointed_thing
|
||||
-- check if pointing at a node
|
||||
@ -43,8 +53,24 @@ local stem_on_place = function(itemstack, placer, pointed_thing)
|
||||
end
|
||||
|
||||
-- add the node and remove 1 item from the itemstack
|
||||
minetest.add_node(pt.above, {name = itemstack:get_name(), param2 = new_param2})
|
||||
if not minetest.settings:get_bool("creative_mode", false) then
|
||||
local newnode= {name = itemstack:get_name(), param2 = new_param2, param1=0}
|
||||
local oldnode= minetest.get_node(pt.above)
|
||||
minetest.add_node(pt.above, newnode)
|
||||
|
||||
-- Run script hook
|
||||
local take_item = true
|
||||
for _, callback in ipairs(core.registered_on_placenodes) do
|
||||
-- Deepcopy pos, node and pointed_thing because callback can modify them
|
||||
local place_to_copy = vector.copy(pt.above)
|
||||
local newnode_copy = {name=newnode.name, param1=newnode.param1, param2=newnode.param2}
|
||||
local oldnode_copy = {name=oldnode.name, param1=oldnode.param1, param2=oldnode.param2}
|
||||
local pointed_thing_copy = copy_pointed_thing(pointed_thing)
|
||||
if callback(place_to_copy, newnode_copy, placer, oldnode_copy, itemstack, pointed_thing_copy) then
|
||||
take_item = false
|
||||
end
|
||||
end
|
||||
|
||||
if (not minetest.settings:get_bool("creative_mode", false)) and take_item then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
Loading…
Reference in New Issue
Block a user