Walkover

A library to make it easier for developers to detect on_walk_over

API / Library

Download (5 KB)

How do I install this?

Some mod developers have shown an interest in having an on_walk_over event. This is useful for pressure-plates and the like.

See this issue - https://github.com/minetest/minetest/issues/247

I have implemented a server_side version in lua using globalstep which people might find useful. Of course this would better implemented via a client-based "on walk over", but it is sufficient for my needs now.

Example Usage

minetest.register_node("somemod:someblock", {
    description = key,
    tiles = {"somemod_someblock.png"},
    groups = {cracky=1},
    on_walk_over = function(pos, node, player)
        minetest.chat_send_player(player, "Hey! Watch it!")
    end,
})

Reviews

Review

Do you recommend this mod?

  • Much needed feature, but a poor implementation

    • The globalsteps runs only once per second (!); this is way too poor granularity. It could be a lot smoother if it ran as often as possible since it is a rather cheap globalstep.
    • Insufficient approach: This subtracts one from the player pos on the vertical axis. Player pos is a feet pos however. Thus this will fail horribly when standing on slabs and is always on the verge of failing (due to precision errors) when standing on full / almost full nodes. A more accurate approach would only subtract a small epsilon from the feet pos and take node boxes into account (e.g. when standing on smaller nodes (slabs) or larger nodes (doors)).
    • Misc. other (minor-ish) code quality issues:
      • Use of deprecated methods: player:getpos() (should trigger a warning?) and {x=...,y=...,z=...} vector (rather than vector.offset).
      • Unnecessary loc ~= nil check.
      • Poor formatting: Inconsistent use of indentation & semicolons.
      • Custom fields should use underscore prefixes. This mod does not abide by that convention for on_walk_over.

    In conclusion, I would strongly advise against depending on this library in its current state. Modders should rather roll their own.

    0 comments