Node Touch Action

Pass in a node name and a function, and every time a player touches that node, the function happens

Developer Tools API / Library

Download (717 KB)

How do I install this?

Pass in a node name and a function, and every time a player touches that node, your custom function executes. This mod is heavilly based on the cactus_damage mod by VMan_2002

Example:

When adding gameplay, one thing that comes in handy is performing an action when a player touches a node. For example making a player take hitpoint damage when touching a cactus. In my Hero Mines game I needed a light to break when a player touched it, and for the player to take damage when touching magma nodes. You can see the magma example below.

Usage:

Add the node_touch_action to the depends statement in your mod.conf file:

depends = default, node_touch_action

After you register your node create a function to be executed when the node is touched:

local function magmaTouchAction(player)
    player:set_hp(player:get_hp() - 1, "magma")
end

Then Register the action to occur when node is touched. The first parameter is the node name, the second parameter is the function that happens when the node is touched.

registerNodeTouchAction("hero_mines:magma", magmaTouchAction)

Reviews

Review

Do you recommend this mod?

  • xX~ rlly nice abstraction layer ^.^~Xx

    does what it is intented for, no extraneous stuff

    Oddly depends on 'default'. May be freely omitted as no dependant elements detected inside Modification.

    using this thing, i did a crossover with 'corngirl' and made her spawn much more frequently when the player attempts to step on corn

    for that, i took some of my old code from the 'bakov' mod (to calculate a random point on a circumference at a given radius around the player) and transformed it into a raycasting device

    very cool i like it even more after making amod with it

    1 comments

Used By