Upload it 🍞
This commit is contained in:
commit
58a6db73d6
13
README.md
Normal file
13
README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Stapled Bread
|
||||
|
||||
## Description
|
||||
|
||||
![Screenshot](https://raw.githubusercontent.com/SmallJoker/stapled_bread/master/screenshot.png)
|
||||
|
||||
This Minetest mod makes it possible to staple bread to trees. Enjoy.
|
||||
To staple the regular bread, craft it to slices and staple it to the tree.
|
||||
|
||||
License: CC0
|
||||
|
||||
## Craft recipes
|
||||
1. Download and install a craft guide
|
1
depends.txt
Normal file
1
depends.txt
Normal file
@ -0,0 +1 @@
|
||||
farming
|
61
init.lua
Normal file
61
init.lua
Normal file
@ -0,0 +1,61 @@
|
||||
local function try_staple(itemstack, placer, pointed)
|
||||
if pointed.type ~= "node" then
|
||||
return
|
||||
end
|
||||
if pointed.above.y - pointed.under.y ~= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
-- Node under must be a tree
|
||||
local node_under = minetest.get_node(pointed.under)
|
||||
local def_under = minetest.registered_nodes[node_under.name] or {}
|
||||
if not def_under.groups or not def_under.groups.tree then
|
||||
return
|
||||
end
|
||||
if def_under.paramtype2 == "facedir"
|
||||
or def_under.paramtype2 == "colorfacedir" then
|
||||
-- Only vertical facedirs are allowed
|
||||
local dir = minetest.wallmounted_to_dir(node_under.param2)
|
||||
if dir.x ~= 0 or dir.z ~= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Node above must be airlike, but not ignore
|
||||
local node_above = minetest.get_node(pointed.above)
|
||||
local def_above = minetest.registered_nodes[node_above.name] or {}
|
||||
if node_above.name == "ignore" or not def_above.buildable_to then
|
||||
return
|
||||
end
|
||||
|
||||
-- Staple to the tree
|
||||
local dir = vector.direction(pointed.above, pointed.under)
|
||||
local obj = minetest.add_entity(
|
||||
vector.add(vector.multiply(dir, 0.49), pointed.above),
|
||||
"stapled_bread:bread_slice"
|
||||
)
|
||||
if obj then
|
||||
local entity = obj:get_luaentity()
|
||||
if not creative or not creative.is_enabled_for(
|
||||
placer:get_player_name()) then
|
||||
itemstack:take_item(1)
|
||||
end
|
||||
entity.object:set_yaw(math.atan2(-dir.x, dir.z))
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
minetest.register_entity("stapled_bread:bread_slice", {
|
||||
visual = "wielditem",
|
||||
textures = { "farming:bread" },
|
||||
visual_size = {x = 0.2, y = 0.2},
|
||||
physical = false,
|
||||
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
|
||||
selectionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1}
|
||||
})
|
||||
|
||||
minetest.override_item("farming:bread", {
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
return try_staple(itemstack, placer, pointed_thing) or itemstack
|
||||
end
|
||||
})
|
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 69 KiB |
Loading…
x
Reference in New Issue
Block a user