[Mod] Delete unknown blocks and objects [1] [clean]

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

[Mod] Delete unknown blocks and objects [1] [clean]

by PilzAdam » Post

Hello everyone!
This is a very simple mod that deletes unkown blocks and removes unkown entities. Just insert there names in the tables in the first two lines and they will be removed when a player is close to them.

Depends:
nothing

License:
Sourcecode: WTFPL

Download:
http://ompldr.org/vZjM5MA/clean.zip Broken (R.I.P. omploader)
Anyway, here is the init.lua:

Code: Select all

local old_nodes = {"mod:a", "mod:b"}
local old_entities = {}

for _,node_name in ipairs(old_nodes) do
    minetest.register_node(":"..node_name, {
        groups = {old=1},
    })
end

minetest.register_abm({
    nodenames = {"group:old"},
    interval = 1,
    chance = 1,
    action = function(pos, node)
        minetest.env:remove_node(pos)
    end,
})

for _,entity_name in ipairs(old_entities) do
    minetest.register_entity(":"..entity_name, {
        on_activate = function(self, staticdata)
            self.object:remove()
        end,
    })
end
Last edited by PilzAdam on Sat Jun 08, 2013 22:19, edited 1 time in total.

mauvebic
Member
Posts: 1550
Joined: Fri Jan 27, 2012 11:32

by mauvebic » Post

Feature request: renaming/migration

Say when you change the name of your mod, or the node, that you could do something like

Code: Select all

nodeswitch('teacup:teacup','tea:cup')
example use: i have a map that uses staircase, which ive updated and renamed since then to nbu, along with some of the nodenames. I cant switch the old mod for the new mod without ruining my map and i dont want to remove the UB's, just switch 'em :-)

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

by PilzAdam » Post

mauvebic wrote:Feature request: renaming/migration

Say when you change the name of your mod, or the node, that you could do something like

Code: Select all

nodeswitch('teacup:teacup','tea:cup')
example use: i have a map that uses staircase, which ive updated and renamed since then to nbu, along with some of the nodenames. I cant switch the old mod for the new mod without ruining my map and i dont want to remove the UB's, just switch 'em :-)
From lua-api.txt

Code: Select all

minetest.register_alias(new_name, old_name)
After that you can use both in code and game, new_name and old_name.
Last edited by PilzAdam on Mon Aug 13, 2012 11:53, edited 1 time in total.

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

Thank you. +1

User avatar
Neuromancer
Member
Posts: 958
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

by Neuromancer » Post

+1. Nice.

sfan5
Moderator
Posts: 4094
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

+1
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
RabbiBob
Member
Posts: 335
Joined: Sat Jan 28, 2012 22:40
Location: /teleport 54,47,28
Contact:

by RabbiBob » Post

+1

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

by rubenwardy » Post

How to use?

local old_nodes = {xpanes:pane} does not work
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

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

by PilzAdam » Post

rubenwardy wrote:How to use?

local old_nodes = {xpanes:pane} does not work

Code: Select all

local old_nodes = {"xpanes:pane"}

User avatar
xyz
Member
Posts: 450
Joined: Thu Nov 10, 2011 14:25

by xyz » Post

rubenwardy wrote:How to use?

local old_nodes = {xpanes:pane} does not work
That will not work, to remove panes you should do it in such way:

Code: Select all

local old_nodes = {"xpanes:pane_1", "xpanes:pane_2" [and so on] "xpanes:pane_15"}

User avatar
RabbiBob
Member
Posts: 335
Joined: Sat Jan 28, 2012 22:40
Location: /teleport 54,47,28
Contact:

by RabbiBob » Post

Good job on this mod. Came in really handy this morning as I'm resurrecting an old server and tossing out old mods that has been resulting in a load of orphaned nodes. As long as you keep track of the console window to get the name, it's a snap to add them to the init.lua, bump the server and away the blocks go.

User avatar
SegFault22
Member
Posts: 872
Joined: Mon May 21, 2012 03:17
Location: NaN

by SegFault22 » Post

+1
"All we need it the right major crisis and the nations will accept the new world order."

dleong21

by dleong21 » Post

I'm trying to remove the animals mod as it keeps crashing minetest, I've already removed the mod folder. I try running this mod with the following line

Code: Select all

 local old_nodes = {"animal_vombie:vombie","animal_dm:dm","animal_big_red:big_red","animal_chicken:chicken","animal_clownfish:clownfish","animal_cow:cow","animal_creeper:creeper","animal_deer:deer","animal_fish_blue_white:fish_blue_white","animal_gull:gull","animal_sheep:sheep","animal_wolf:wolf"} 
But this doesnt seem to be working, am I missing something?

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

use old_entities for animals.

Code: Select all

local old_entities = {"animal_vombie:vombie","animal_dm:dm","animal_big_red:big_red","animal_chicken:chicken","animal_clownfish:clownfish","animal_cow:cow","animal_creeper:creeper","animal_deer:deer","animal_fish_blue_white:fish_blue_white","animal_gull:gull","animal_sheep:sheep","animal_wolf:wolf"}

Dragonop
Member
Posts: 1233
Joined: Tue Oct 23, 2012 12:59
GitHub: Dragonop
IRC: Dragonop
In-game: Dragonop
Location: Argentina

by Dragonop » Post

YOU ARE MY HERO all tose ''old'' trees from mods and that can disapear COOL!

BenAmaranth
Member
Posts: 60
Joined: Thu Oct 04, 2012 15:14

by BenAmaranth » Post

ModError: Failed to load and run C:\User\Bgreco\Desktop\Newfoldergames\minetest-0.4.4-win32\bin\..\mods\minetest\clean\init.lua
Last edited by BenAmaranth on Sat Jan 19, 2013 19:49, edited 1 time in total.
Air (you hacker you!)

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

by PilzAdam » Post

BenAmaranth wrote:ModError: Failed to laod and run C:\User\Bgreco\Desktop\Newfoldergames\minetest-0.4.4-win32\bin\..\mods\minetest\clean\init.lua
Can you post the last ~20 lines of your debug.txt in the bin/ folder?

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

by PilzAdam » Post

BenAmaranth wrote:
PilzAdam wrote:
BenAmaranth wrote:ModError: Failed to laod and run C:\User\Bgreco\Desktop\Newfoldergames\minetest-0.4.4-win32\bin\..\mods\minetest\clean\init.lua
Can you post the last ~20 lines of your debug.txt in the bin/ folder?

Code: Select all

13:50:18: ERROR[main]: ========== ERROR FROM LUA ===========
13:50:18: ERROR[main]: Failed to load and run script from 
13:50:18: ERROR[main]: C:\Users\Bgreco\Desktop\New foldergames\minetest-0.4.4-win32\bin\..\mods\minetest\clean\init.lua:
13:50:18: ERROR[main]: ...New foldergames\minetest-0.4.4-win32\bin\..\mods\minetest\clean\init.lua:3: 'in' expected near '}'
13:50:18: ERROR[main]: =======END OF ERROR FROM LUA ========
13:50:18: ERROR[main]: Server: Failed to load and run C:\Users\Bgreco\Desktop\New foldergames\minetest-0.4.4-win32\bin\..\mods\minetest\clean\init.lua
13:50:18: INFO[main]: BanManager: saving to C:\Users\Bgreco\Desktop\New foldergames\minetest-0.4.4-win32\bin\..\worlds\Hmmm\ipban.txt
13:50:19: ERROR[main]: ModError: Failed to load and run C:\Users\Bgreco\Desktop\New foldergames\minetest-0.4.4-win32\bin\..\mods\minetest\clean\init.lua
13:50:19: INFO[main]: Searching worlds...
13:50:19: INFO[main]:   In C:\Users\Bgreco\Desktop\New foldergames\minetest-0.4.4-win32\bin\..\worlds: 
13:50:19: INFO[main]: Hmmm moremods 
13:50:19: INFO[main]: 2 found.
13:50:19: INFO[main]: Waiting for other menus
13:50:19: INFO[main]: Waited for other menus
13:50:19: VERBOSE[main]: error_message = ModError: Failed to load and run C:\Users\Bgreco\Desktop\New foldergames\minetest-0.4.4-win32\bin\..\mods\minetest\clean\init.lua
13:50:19: VERBOSE[main]: Check debug.txt for details.
13:50:19: INFO[main]: Created main menu
13:50:19: INFO[main]: locale has been set to:English_United States.1252
13:50:19: INFO[main]: locale has been set to:C
13:50:21: INFO[main]: locale has been set to:English_United States.1252
13:50:21: INFO[main]: locale has been set to:C
13:50:26: INFO[main]: Dropping main menu
13:50:26: INFO[main]: Updating configuration file: "C:\Users\Bgreco\Desktop\New foldergames\minetest-0.4.4-win32\bin\..\minetest.conf"
13:50:26: INFO[main]: Skipping writing of C:\Users\Bgreco\Desktop\New foldergames\minetest-0.4.4-win32\bin\..\minetest.conf because content wouldn't be modified
Can you post your first 2 lines of the init.lua?

BenAmaranth
Member
Posts: 60
Joined: Thu Oct 04, 2012 15:14

by BenAmaranth » Post

Caught it upon examining the back up. Deleted one of these guys --> }
Air (you hacker you!)

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

by PilzAdam » Post

BenAmaranth wrote:

Code: Select all

local old_nodes = {"snow:dirt_with_snow", "snow:snow", "snow:ice"}

for _,node}
local old_entities = {_name in ipairs(old_nodes)
You messed it up a bit :-)
Here are the correct first 8 lines:

Code: Select all

local old_nodes = {"snow:dirt_with_snow", "snow:snow", "snow:ice"}
local old_entities = {}

for _,node_name in ipairs(old_nodes) do
    minetest.register_node(":"..node_name, {
        groups = {old=1},
    })
end

BenAmaranth
Member
Posts: 60
Joined: Thu Oct 04, 2012 15:14

by BenAmaranth » Post

Edit: Deleted old posts, thanks PilzAdam
Air (you hacker you!)

socramazibi
Member
Posts: 81
Joined: Mon Jan 28, 2013 12:29
Location: España

by socramazibi » Post

Thanks, I found it very useful.
Forgive my English, but it is the translator of google.My Spanish.
My mod:
Pictures wool 1.0 3x5 , Charcoal+Textures , Map

User avatar
BrandonReese
Member
Posts: 839
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese
Location: USA

by BrandonReese » Post

Can you upload this to your dropbox or somewhere that actually works :-)

User avatar
Casimir
Member
Posts: 1206
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

by Casimir » Post

Code: Select all

local old_nodes = {"mod:a", "mod:b"}
local old_entities = {}

for _,node_name in ipairs(old_nodes) do
    minetest.register_node(":"..node_name, {
        groups = {old=1},
    })
end

minetest.register_abm({
    nodenames = {"group:old"},
    interval = 1,
    chance = 1,
    action = function(pos, node)
        minetest.env:remove_node(pos)
    end,
})

for _,entity_name in ipairs(old_entities) do
    minetest.register_entity(":"..entity_name, {
        on_activate = function(self, staticdata)
            self.object:remove()
        end,
    })
end

keyxmakerx
Member
Posts: 104
Joined: Mon Apr 08, 2013 23:53

by keyxmakerx » Post

Any news when the download will be fixed?

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests