GamingAssociation39
Member
Posts: 858 Joined: Mon Apr 25, 2016 16:09
GitHub:
Gerold55
IRC: Gerold55
In-game: Gerold55
Location: Maryland, USA
by GamingAssociation39 » Thu Aug 16, 2018 15:25
Post
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!!!
rubenwardy
Moderator
Posts: 6978 Joined: Tue Jun 12, 2012 18:11
GitHub:
rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:
by rubenwardy » Thu Aug 16, 2018 15:29
Post
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
ChimneySwift
Member
Posts: 320 Joined: Fri Sep 22, 2017 06:46
GitHub:
ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1
by ChimneySwift » Fri Aug 17, 2018 06:55
Post
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
rubenwardy
Moderator
Posts: 6978 Joined: Tue Jun 12, 2012 18:11
GitHub:
rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:
by rubenwardy » Fri Aug 17, 2018 09:36
Post
Yeah, and it's also not a valid position
Users browsing this forum: No registered users and 7 guests