Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
38ba241f0c | |||
168180ea34 |
24
airblock.lua
24
airblock.lua
@ -1,7 +1,19 @@
|
|||||||
local S = minetest.get_translator("tech_additions")
|
local S = minetest.get_translator("tech_additions")
|
||||||
|
|
||||||
|
local replace_allowed = {}
|
||||||
|
replace_allowed["air"] = true
|
||||||
|
replace_allowed["default:water_source"] = true
|
||||||
|
replace_allowed["default:water_flowing"] = true
|
||||||
|
replace_allowed["default:river_water_source"] = true
|
||||||
|
replace_allowed["default:river_water_flowing"] = true
|
||||||
|
|
||||||
local placeairblock = function ()
|
local placeairblock = function ()
|
||||||
return function(itemstack, user, pointed_thing)
|
return function(itemstack, user, pointed_thing)
|
||||||
|
local name = user:get_player_name()
|
||||||
|
if not minetest.is_creative_enabled(name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local pos = user:getpos()
|
local pos = user:getpos()
|
||||||
local dir = user:get_look_dir()
|
local dir = user:get_look_dir()
|
||||||
local distancefromplayer = 3
|
local distancefromplayer = 3
|
||||||
@ -10,12 +22,14 @@ local placeairblock = function ()
|
|||||||
y = pos.y + 1 + (dir.y * distancefromplayer),
|
y = pos.y + 1 + (dir.y * distancefromplayer),
|
||||||
z = pos.z + (dir.z * distancefromplayer),
|
z = pos.z + (dir.z * distancefromplayer),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if minetest.is_protected(new_pos, name) then
|
||||||
|
minetest.record_protection_violation(new_pos, name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local getPos = minetest.get_node(new_pos)
|
local getPos = minetest.get_node(new_pos)
|
||||||
if getPos.name == "air" or
|
if replace_allowed[getPos.name] then
|
||||||
getPos.name == "default:water_source" or
|
|
||||||
getPos.name == "default:water_flowing" or
|
|
||||||
getPos.name == "default:river_water_source" or
|
|
||||||
getPos.name == "default:river_water_flowing" then
|
|
||||||
minetest.set_node(new_pos, {name="tech_additions:air_block"})
|
minetest.set_node(new_pos, {name="tech_additions:air_block"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,6 +1,6 @@
|
|||||||
name = tech_additions
|
name = tech_additions
|
||||||
description = Adds some block and recipes.
|
description = Adds some block and recipes.
|
||||||
depends = default, techage
|
depends = default, techage
|
||||||
optional_depends = bbq, bonemeal, craft_ingredients, ethereal, farming
|
optional_depends = bbq, bonemeal, craft_ingredients, ethereal, farming, smartshop
|
||||||
min_minetest_version = 5.7
|
min_minetest_version = 5.7
|
||||||
title = Tech additions
|
title = Tech additions
|
52
techage.lua
52
techage.lua
@ -68,3 +68,55 @@ techage.add_grinder_recipe({input="default:ice", output="default:snow 3"})
|
|||||||
|
|
||||||
--add extra sieving
|
--add extra sieving
|
||||||
dofile(minetest.get_modpath("tech_additions") .. "/sieving.lua")
|
dofile(minetest.get_modpath("tech_additions") .. "/sieving.lua")
|
||||||
|
|
||||||
|
local OwnerCache = {}
|
||||||
|
|
||||||
|
local function is_owner(pos, meta)
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
|
local key = minetest.hash_node_position(pos)
|
||||||
|
if OwnerCache[key] ~= owner then
|
||||||
|
if not minetest.is_protected(pos, owner) then
|
||||||
|
OwnerCache[key] = owner
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return OwnerCache[key] == owner
|
||||||
|
end
|
||||||
|
|
||||||
|
if smartshop then
|
||||||
|
techage.register_node(
|
||||||
|
{
|
||||||
|
"smartshop:shop",
|
||||||
|
"smartshop:shop_full",
|
||||||
|
"smartshop:shop_empty",
|
||||||
|
"smartshop:shop_used",
|
||||||
|
"smartshop:storage",
|
||||||
|
"smartshop:storage_lacks_refill",
|
||||||
|
"smartshop:storage_has_send"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
on_inv_request = function(pos, in_dir, access_type)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if is_owner(pos, meta) then
|
||||||
|
return meta:get_inventory(), "main"
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_pull_item = function(pos, in_dir, num)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if is_owner(pos, meta) then
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return techage.get_items(pos, inv, "main", num)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_push_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return techage.put_items(inv, "main", stack)
|
||||||
|
end,
|
||||||
|
on_unpull_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return techage.put_items(inv, "main", stack)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user