Many things:

* Use global variable throwing.modname instead of local modname
* Use minetest.place_node instead of minetest.set_node for torch arrow and build arrow
* Add an error return value to the on_hit function
This commit is contained in:
upsilon
2017-01-12 20:49:42 +01:00
parent e7ae9a01cf
commit a6ce9315b0
3 changed files with 51 additions and 20 deletions

View File

@ -54,6 +54,8 @@ On_hit: callback function: on_hit(pos, last_pos, node, object, hitter) where:
whether the arrow hitted a node or an object (you should always check for that).
An object can be a player or a luaentity.
* Hitter: the ObjectRef of the player who throwed the arrow.
* When it fails, it should return:
false[, reason]
]]
-- Examples:
@ -74,6 +76,10 @@ function(pos, last_pos, node, object, hitter)
if not node then
return
end
minetest.set_node(last_pos, {name="default:obsidian_glass"})
if minetest.is_protected(last_pos) then
return false, "Area is protected"
end
return minetest.place_node(last_pos, {name="default:obsidian_glass"})
end)
```