Node Touch Action

Description

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

Releases

2024-05-12

Download

2024-05-12 02:24 UTC

2024-05-12 🔗

No release notes

get touched node pos function

Download

2024-04-06 18:01 UTC

get touched node pos function 🔗

No release notes

Fix touch above

Download

2024-03-24 17:08 UTC

Fix touch above 🔗

No release notes

removed depends on default

Download

2024-03-09 00:12 UTC

removed depends on default 🔗

No release notes

Expanded y touch range

Download

2024-03-03 23:29 UTC

Expanded y touch range 🔗

No release notes

All releases

Information

Provides

node_touch_action

Dependencies

Required
No required dependencies

Information

Type
Mod
Technical Name
node_touch_action
Languages
English
License
MIT
Maintenance State
Actively Developed
Added
2024-03-03 19:59 UTC
Maintainers
Neuromancer

Used By