Compare commits

...

5 Commits

Author SHA1 Message Date
isaiah658 99e0e22b45
Remove unused variable
Forgot to remove the player name variable after removing the protection check.
2018-07-01 08:28:52 -05:00
isaiah658 3ea965f45d
Remove protection check
I had an oversight in my code. Because the node space is being checked for air, there is no reason to check the node space for protection permissions.
2018-06-30 14:25:28 -05:00
isaiah658 5591e13062
Check for existing node, add recipe, lower anchor placement
This adds a check to ensure that the floating anchor is only placed in a node space that is occupied by air. A recipe was added to allow crafting the floating anchor. The anchor placement was lowered to place the block below the player's feet instead of inside of the player.
2018-06-30 14:03:42 -05:00
isaiah658 4a3f362a4e
Add depends.txt
Needed due to adding a crafting recipe which uses the default mod.
2018-06-30 13:49:21 -05:00
Starbeamrainbowlabs a10fe18ee7
Add link to furm post 2018-05-28 17:19:48 +01:00
3 changed files with 20 additions and 4 deletions

View File

@ -1,8 +1,10 @@
# minetest-floating-anchor
A floating anchor mod for minetest. Adds an item that, when used, places a floating anchor block at the player's position.
> A floating anchor mod for minetest. Adds an item that, when used, places a floating anchor block at the player's position.
![A picture of the floating anchor block in mid-air.](https://i.imgur.com/4RYlEDO.png)
- [Forum Post](https://forum.minetest.net/viewtopic.php?f=9&t=20180)
## Installation
Clone this repository into the `worldmods` subfolder of the folder that contains your world. If it doesn't exist, then you'll need to create it.

1
depends.txt Normal file
View File

@ -0,0 +1 @@
default

View File

@ -15,13 +15,17 @@ local function do_anchor_place(itemstack, player, pointed_thing)
-- Figure out where to put the anchor
local place_position = player:getpos()
place_position.y = place_position.y - 0.8
log_message("action", string.format("(%d, %d, %d)", place_position.x, place_position.y, place_position.z))
-- Place the floating anchor in the world
minetest.set_node(place_position, { name = "floating_anchor:floating_anchor" })
local node_to_check = minetest.get_node(place_position)
if node_to_check.name == "air" then
minetest.set_node(place_position, { name = "floating_anchor:floating_anchor" })
-- Take an item from the player's stack & return the new stack with 1 fewer items in it
itemstack:take_item(1)
end
-- Take an item from the player's stack & return the new stack with 1 fewer items in it
local new_itemstack = itemstack:take_item(1)
return itemstack
end
@ -39,4 +43,13 @@ minetest.register_craftitem("floating_anchor:floating_anchor_item", {
on_secondary_use = do_anchor_place
})
minetest.register_craft({
output = "floating_anchor:floating_anchor",
recipe = {
{"group:wool", "group:wool", "group:wool"},
{"group:wool", "default:steel_ingot", "group:wool"},
{"group:wool", "group:wool", "group:wool"},
}
})
log_message("info", "Loaded!")