External script for /deleteblocks

User avatar
orwell
Member
 
Posts: 467
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
In-game: orwell

External script for /deleteblocks

by orwell » Sat Jan 09, 2016 19:52

Hi.
This script does the same as the chatcommand /deleteblocks, but better.
- faster, because it specifies multiple mapblock deletions in one query
- progress indicator
- allows for deleting mapblocks outside the specific area.

Install:

needed packages:
-lua
-luarocks
-libsqlite3-dev

1. install packages using your distro's package manager
2. run the following command to install the lua sqlite support

luarocks install lsqlite3

if this command aborts with something like "sqlite3.h not found", you probably haven't installed libsqlite3-dev

3. done


Run:

lua deleteblocks.lua path_to_map_sqlitedb minx miny minz maxx maxy maxz [invert]

Use node coords, (-)32000 or so for infinite, the block the node is in will stay as the last block.
invert clears everything outside the defined area. (give any value that is not nothing)

How it works and what makes it fast:
1. scan all existing mapblocks and check if they have to be deleted. collect them. This is to prevent masses of useless "delete" queries to be issued.
2. issue delete queries, but with 50 (can be configured in the file) pos=<map_block_id> statements connected with 'or'. So, the database driver does not have to scan the whole database for one deletion, but the queries do not get too long.
Attachments
deleteblocks.zip
(1.95 KiB) Downloaded 61 times
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
orwell
Member
 
Posts: 467
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
In-game: orwell

Re: External script for /deleteblocks

by orwell » Mon Jan 11, 2016 19:33

Warning
Found a typo with bad consequences (it took the y coord where it should take x)
It has now been fixed. Please re-download!
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 


Return to Minetest-Related

Who is online

Users browsing this forum: No registered users and 28 guests

cron