External script for /deleteblocks

Post Reply
User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

External script for /deleteblocks

by orwell » Post

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 43 times
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

Re: External script for /deleteblocks

by orwell » Post

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...

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests