Page 1 of 1

External script for /deleteblocks

PostPosted: Sat Jan 09, 2016 19:52
by orwell
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.

Re: External script for /deleteblocks

PostPosted: Mon Jan 11, 2016 19:33
by orwell
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!