Stop mesecons pistons extending

batnoob
Member
 
Posts: 10
Joined: Mon May 14, 2018 21:28
In-game: TheIncredibleHulk

Stop mesecons pistons extending

by batnoob » Wed Sep 11, 2019 16:05

I am trying to mod the mesecons mod so that pistons and movestones can be stopped by obsidian like mc, so I don't have to chase flying machines across the map to stop them. Looking through the piston code I found this line
Code: Select all
local success, stack, oldstack = mesecon.mvps_push(pusher_pos, dir, max_push)
   if not success then
      return
   end

If I were to make a function that checks the node the piston is pushing and treat finding obsidian like finding 20 nodes, would that stop the piston?
How would I check all 20 nodes in front of it for obsidian in case the obsidian isn't right in front of the piston?
Is there any node that does stop a piston so I don't have to do all this work?
 

micheal65536
Member
 
Posts: 110
Joined: Mon May 22, 2017 20:27

Re: Stop mesecons pistons extending

by micheal65536 » Mon Sep 16, 2019 15:03

This should do it:
Code: Select all
mesecon.register_mvps_stopper("default:obsidian")

You can obviously replace "default:obsidian" with whatever node you want to act as a stopper.

Obviously this only works if mesecons is installed and will crash during loading otherwise, so you should probably wrap it as follows:
Code: Select all
if minetest.get_modpath("mesecons_mvps") ~= nil then
    mesecon.register_mvps_stopper("default:obsidian")
end

You'll need to put this code in your own mod. Make sure to include mesecons_mvps as an optional dependency. If you only care about Minetest 5.0.0 and later you should create a file in your mod directory called "mod.conf" and put the line "optional_depends = mesecons_mvps" inside. If you also want it to work on Minetest 0.4.x then create a file called "depends.txt" and add the line "mesecons_mvps?".
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 2 guests