Page 1 of 1

Change a node for another in the whole server

PostPosted: Mon Jan 06, 2014 21:24
by MasterGollum
I recently migrated from 0.4.3 to 0.4.8 all the changes are impressive and really cool, but I have a little big problem. I have already created large extensions of buildings with cobble stone, now the texture has more sense, but I would not had used that nodes from the begining if that texture was the existing in that time. I don't want to change the default texture, I like it, I think it is better than the previous one, I just want to transform my cobbles to stone bricks that is just what they were looking until now.

In short, exists a way to massive change all the cobble stones (or any other node) to another existing one? I opened the database, but there all the blocks are just blobs :( so I can't perform a SQL update. I don't care about the ones inside inventories or containers, just the placed ones.

PostPosted: Mon Jan 06, 2014 22:01
by Pitriss
try to write simple mod with abm which change all loaded cobble to stone bricks and walk through whole map.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_abm({
    nodenames = {"default:cobble"},
    interval = 10,
    chance = 1,
    action = function(pos)
        minetest.add_node(pos, {name="default:stonebrick"})
    end,
})


as decribed here. This should turn all default:cobble loaded into default:stonebrick every 10s.

PostPosted: Mon Jan 06, 2014 22:21
by rubenwardy
Pitriss wrote:try to write simple mod with abm which change all loaded cobble to stone bricks and walk through whole map.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_abm({
    nodenames = {"default:cobble"},
    interval = 10,
    chance = 1,
    action = function(pos)
        minetest.add_node(pos, {name="default:stonebrick"})
    end,
})


as decribed here. This should turn all default:cobble loaded into default:stonebrick every 10s.


Maybe minetest.set_node, as iirc, add_node requires the position to be air.

PostPosted: Mon Jan 06, 2014 22:23
by Pitriss
oops sorry then. I took that example from dev wiki as I never used abm

PostPosted: Mon Jan 06, 2014 22:26
by aldobr
I predict that after 300 posts containing 600 sugestions of improvement, that "simple" script will become a game mode in itself.

PostPosted: Mon Jan 06, 2014 22:53
by PilzAdam
rubenwardy wrote:
Pitriss wrote:try to write simple mod with abm which change all loaded cobble to stone bricks and walk through whole map.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_abm({
    nodenames = {"default:cobble"},
    interval = 10,
    chance = 1,
    action = function(pos)
        minetest.add_node(pos, {name="default:stonebrick"})
    end,
})


as decribed here. This should turn all default:cobble loaded into default:stonebrick every 10s.


Maybe minetest.set_node, as iirc, add_node requires the position to be air.

add_node and set_node are exactly the same, no difference at all.

PostPosted: Mon Jan 06, 2014 23:06
by MasterGollum
thank you, I will try it tomorrow, I have also other nodes to take care, because I have stairs and slabs. To walk over all the map will be hard :P I have lit. Km of tunnels with that cobbles.

PostPosted: Tue Jan 07, 2014 02:01
by ShadowNinja
You could also try:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_alias("default:cobble", "default:stonebrick")

This might convert items in chests too if you move them, although it will make stone drop stonebrick while it's enabled. Another option is to use WorldEdit and run //replace default:cobble default:stonebrick on all of your structures.

PostPosted: Tue Jan 07, 2014 02:44
by Sokomine
Perhaps the easiest way in such a case might be to simply switch the textures and give cobble the old-cobble-new-stonebricks-texture while giving the current cobble texture to stonebricks. If necessary, stone could turn into stonebricks (with cobble texture) after digging - though that might be confusing for crafting receipes. Perhaps just exchanging the textures might do. The few times you'll actually need the new cobble texture (i.e. for paths), crafting them with a new receipe or as stonebricks might work.

PostPosted: Tue Jan 07, 2014 04:06
by hoodedice
@Sokomine: Nope, ShadowNinja beat me to it. WorldEdit is by far the easiest way to replace nodes in a given area.

PostPosted: Tue Jan 07, 2014 14:13
by MasterGollum
I decided to use the Pitriss's function. It worked fine, but the stairs, they lost the direction :P I fixed it transfering the param2 value to the new nodes. I prefer not to use an aliass because I wanted to leave the default behaviour, so once I changed all I will remove the abm. Luckily I had not used WorldEdit or I would have done a mess with all the stairs :P

PostPosted: Tue Jan 07, 2014 15:41
by hoodedice
MasterGollum wrote:I decided to use the Pitriss's function. It worked fine, but the stairs, they lost the direction :P I fixed it transfering the param2 value to the new nodes. I prefer not to use an aliass because I wanted to leave the default behaviour, so once I changed all I will remove the abm. Luckily I had not used WorldEdit or I would have done a mess with all the stairs :P


Oh dam.

PostPosted: Tue Jan 07, 2014 20:38
by Evergreen
MasterGollum wrote:I decided to use the Pitriss's function. It worked fine, but the stairs, they lost the direction :P I fixed it transfering the param2 value to the new nodes. I prefer not to use an aliass because I wanted to leave the default behaviour, so once I changed all I will remove the abm. Luckily I had not used WorldEdit or I would have done a mess with all the stairs :P
This is why mod creators need to provide abms to replace current blocks with the new version of the block. I had this problem with the quartz mod pillars, which I created an abm for.