Change a node for another in the whole server

Post Reply
User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

Change a node for another in the whole server

by MasterGollum » Post

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.

User avatar
Pitriss
Member
Posts: 254
Joined: Mon Aug 05, 2013 17:09
GitHub: Pitriss
IRC: pitriss
In-game: pitriss
Location: Czech republic, Bohumin

by Pitriss » Post

try to write simple mod with abm which change all loaded cobble to stone bricks and walk through whole map.

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.
I reject your reality and substitute my own. (A. Savage, Mythbusters)
I'm not modding and/or playing minetest anymore. All my mods were released under WTFPL. You can fix/modify them yourself. Don't ask me for support. Thanks.

User avatar
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 » Post

Pitriss wrote:try to write simple mod with abm which change all loaded cobble to stone bricks and walk through whole map.

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.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Pitriss
Member
Posts: 254
Joined: Mon Aug 05, 2013 17:09
GitHub: Pitriss
IRC: pitriss
In-game: pitriss
Location: Czech republic, Bohumin

by Pitriss » Post

oops sorry then. I took that example from dev wiki as I never used abm
I reject your reality and substitute my own. (A. Savage, Mythbusters)
I'm not modding and/or playing minetest anymore. All my mods were released under WTFPL. You can fix/modify them yourself. Don't ask me for support. Thanks.

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

I predict that after 300 posts containing 600 sugestions of improvement, that "simple" script will become a game mode in itself.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

rubenwardy wrote:
Pitriss wrote:try to write simple mod with abm which change all loaded cobble to stone bricks and walk through whole map.

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.

User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Post

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.

User avatar
ShadowNinja
Developer
Posts: 200
Joined: Tue Jan 22, 2013 22:35
GitHub: ShadowNinja
IRC: ShadowNinja
In-game: ShadowNinja

by ShadowNinja » Post

You could also try:

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.
Last edited by ShadowNinja on Tue Jan 07, 2014 02:02, edited 1 time in total.

Sokomine
Member
Posts: 4290
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

by Sokomine » Post

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.
A list of my mods can be found here.

User avatar
hoodedice
Member
Posts: 1374
Joined: Sat Jul 06, 2013 06:33
GitHub: hoodedice
IRC: hoodedice
In-game: hoodedice
Location: world
Contact:

by hoodedice » Post

@Sokomine: Nope, ShadowNinja beat me to it. WorldEdit is by far the easiest way to replace nodes in a given area.
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build

User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Post

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

User avatar
hoodedice
Member
Posts: 1374
Joined: Sat Jul 06, 2013 06:33
GitHub: hoodedice
IRC: hoodedice
In-game: hoodedice
Location: world
Contact:

by hoodedice » Post

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.
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build

User avatar
Evergreen
Member
Posts: 2135
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen
Location: A forest in the midwest
Contact:

by Evergreen » Post

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.
Last edited by Evergreen on Tue Jan 07, 2014 20:38, edited 1 time in total.
Back from the dead!

Post Reply

Who is online

Users browsing this forum: No registered users and 37 guests