Node detection

User avatar
GamingAssociation39
Member
 
Posts: 819
Joined: Mon Apr 25, 2016 16:09
Location: Maryland, USA
GitHub: Gerold55
IRC: Gerold55
In-game: Gerold55

Node detection

by GamingAssociation39 » Thu Aug 16, 2018 15:25

I'm looking for a way to change the nodes when placed next to a similar node. The code below is something that JosiahWI had whipped up but I can't figure out how to get it working.

Code: Select all
minetest.register_abm({
    name = "ma_pops_furniture:table_wood",
    abm = function(node, otherArgs)
        if minetest.get_node{pos.x+1, pos.y, pos.z}.name == "ma_pops_furniture:table_wood" then
            minetest.set_node(pos, "ma_pops_furniture:table_c2_wood")
        elseif minetest.get_node{pos.x+1, pos.y, pos.z}.name == "ma_pops_furniture:table_wood" then
            minetest.set_node(pos, "ma_pops_furniture:table_c2_wood")
        elseif minetest.get_node{pos.x+1, pos.y, pos.z}.name == "ma_pops_furniture:table_wood" then
            minetest.set_node(pos, "ma_pops_furniture:table_c2_wood")
        elseif minetest.get_node{pos.x+1, pos.y, pos.z}.name == "ma_pops_furniture:table_wood" then
            minetest.set_node(pos, "ma_pops_furniture:table_c2_wood")
        end
    end
})
Jesus Is Lord and Savior!!!
 

User avatar
rubenwardy
Moderator
 
Posts: 5863
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Node detection

by rubenwardy » Thu Aug 16, 2018 15:29

1. set_node takes a node, not a node name. So { name = "ma_pops_furniture:table_c2_wood" } not "ma_pops_furniture:table_c2_wood"

2. use parentheses when calling a function like so minetest.get_node({pos.x+1, pos.y, pos.z}).name. Every time you miss the parentheses, a puppy dies
 

User avatar
ChimneySwift
Member
 
Posts: 320
Joined: Fri Sep 22, 2017 06:46
Location: 127.0.0.1
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift

Re: Node detection

by ChimneySwift » Fri Aug 17, 2018 06:55

Is it just me or are you checking the exact same thing 4 times?
A spoon is basically a tiny bowl with a stick on it
 

User avatar
rubenwardy
Moderator
 
Posts: 5863
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
 


Return to Modding Discussion



Who is online

Users browsing this forum: MSN [Bot] and 3 guests