Force land RE-generation

User avatar
redcrab
Member
 
Posts: 831
Joined: Tue Dec 13, 2011 13:45

Force land RE-generation

by redcrab » Fri Feb 10, 2012 08:32

After some modification (digs and places) in a particular area ... I would like to reset the area as it was freshly generated ....

1) first guess
Does a delete of the right records in DB is enough to do the task ...
My though is:
1 record in DB is a 16x16x16 block of nodes ... and if a block do not exist in DB , land generator is invoked
Can I expect some bad side effects ?

2) cool hope
Or is it possible by LUA script to force invocation of land generator on already generated land block of nodes ?

3) other trick ?
Or does it exist other particular trick.
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net

It's nice to be important but it is more important to be nice.
 

kahrl
Member
 
Posts: 236
Joined: Fri Sep 02, 2011 07:51

by kahrl » Fri Feb 10, 2012 08:38

1) Yes, that is possible. You might get some glitches with inter-mapblock structures (like trees), but those glitches exist in the vanilla game anyway.

2) Probably not. You could add a C++ function that could be invoked from lua.

3) ???

Of course there's no in-game way to do this, it would make it far too easy to farm ores.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Fri Feb 10, 2012 09:44

redcrab wrote:After some modification (digs and places) in a particular area ... I would like to reset the area as it was freshly generated ....

1) first guess
Does a delete of the right records in DB is enough to do the task ...
My though is:
1 record in DB is a 16x16x16 block of nodes ... and if a block do not exist in DB , land generator is invoked
Can I expect some bad side effects ?

2) cool hope
Or is it possible by LUA script to force invocation of land generator on already generated land block of nodes ?

3) other trick ?
Or does it exist other particular trick.

You can try "//set ignore" but i think the server prevents this
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

rahonejm
Member
 
Posts: 88
Joined: Wed Dec 28, 2011 01:58

by rahonejm » Fri Feb 10, 2012 14:50

Okay, I tough that it was forcing Resident Evil land generation...
Sorry for possible language mistakes
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Fri Feb 10, 2012 17:38

You can find the record in the database using these calculations:

WARNING: Be sure to save a copy of your 'map.sqlite' file!!!

1)First find the general area that you would like to reset (x,y,z)

2)Next convert these node coords to map block coords:
x = int(x/16)
y = int(y/16)
z = int(z/16)

3)Use these x,y,z to get the database index value
db_pos = (z*16777216 + y*4096 + x)

4)Open map.sqlite (you will need a program to do this; Google it or try http://sourceforge.net/projects/sqlitebrowser/)

5)Execute this SQL statement:
"DELETE BROM blocks WHERE pos = db_pos;"
Be sure to replace 'db_pos' with the number you got in step 3.

6)Repeat as needed.

----------------------------------------------------------
Here is some LUA code that will make an SQL statement for you that will delete everything except for blocks in the defined area. To delete only blocks in the defined area, you just need to remove the word 'NOT' in the SQL statement. (NOTE: this in not a mod. You need the standalone LUA program to run this. (LUA for Windows)


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
-- These numbers are node values
x_min = -300
x_max = 300

y_min = -20
y_max = 100

z_min = -300
z_max = 300


x_min = math.floor(x_min / 16)-1
x_man = math.floor(x_man / 16)+1

y_min = math.floor(y_min / 16)-1
y_man = math.floor(y_man / 16)+1

z_min = math.floor(z_min / 16)-1
z_man = math.floor(z_man / 16)+1

function GetBlockInt(x, y, z)
    return (z*16777216 + y*4096 + x)
end

sql = "DELETE FROM blocks WHERE pos NOT IN ("

for x = x_min, x_max do
for y = y_min, y_max do
for z = z_min, z_max do
    sql = sql .. GetBlockInt(x,y,z)
    if x == x_max and y == y_max and z == z_max then
        sql = sql .. ")"
    else
        sql = sql .. ", "
    end
end
end
end


f = io.open ("runthis_sql" , "w+")
f:write(sql)
f:close()
Last edited by randomproof on Fri Feb 10, 2012 17:41, edited 1 time in total.
 

User avatar
redcrab
Member
 
Posts: 831
Joined: Tue Dec 13, 2011 13:45

by redcrab » Fri Feb 10, 2012 17:59

thanks for the resources :)
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net

It's nice to be important but it is more important to be nice.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 40 guests

cron