example code and ship blueprints added
commit
f3b56cdd4d
|
@ -0,0 +1,5 @@
|
|||
This is a mod for MineTest.
|
||||
|
||||
It spawns pre-built ships and rafts at mapgen time on water.
|
||||
|
||||
Depends on handle_schematics.
|
|
@ -0,0 +1 @@
|
|||
handle_schematics
|
|
@ -0,0 +1,79 @@
|
|||
|
||||
ships_on_mapgen = {}
|
||||
|
||||
-- if set to 100: place one ship in each mapchunk if possible;
|
||||
-- if set to a lower value: percent chance of placing a ship
|
||||
-- in a mapchunk
|
||||
ships_on_mapgen.probability_per_mapchunk = 100;
|
||||
|
||||
ships_on_mapgen.schematics = {
|
||||
-- yoff: how deep is the ship burried in water?
|
||||
-- {scm="boat", typ="ship", is_ship=true, yoff=-1, orients={0}},
|
||||
-- {scm="shipc_4_270", typ="ship", is_ship=true, orients={0}}
|
||||
|
||||
-- big sailing ship
|
||||
{scm="ship_sokomine_big_3_180", typ="ship", is_ship=true, orients={0}},
|
||||
-- some smaller rafts
|
||||
-- raft for general transport purposes
|
||||
{scm="raft_1_2_180", typ="ship", is_ship=true, orients={0}},
|
||||
-- raft with fences for transporting passagers or cattle
|
||||
{scm="raft_2_2_180", typ="ship", is_ship=true, orients={0}},
|
||||
-- raft with hut on it
|
||||
{scm="raft_3_2_180", typ="ship", is_ship=true, orients={0}},
|
||||
}
|
||||
|
||||
|
||||
ships_on_mapgen.mts_path = minetest.get_modpath( minetest.get_current_modname() ).."/schems/";
|
||||
|
||||
-- determine the size of the given houses and other necessary values
|
||||
for i,v in ipairs( ships_on_mapgen.schematics ) do
|
||||
v.mts_path = ships_on_mapgen.mts_path;
|
||||
v.is_ship = true;
|
||||
v.typ = "ship";
|
||||
ships_on_mapgen.schematics[ i ] = handle_schematics.analyze_file( nil, nil, v.mts_path .. v.scm, v, false );
|
||||
end
|
||||
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
-- no point in placing boats on mountains or deep below sealevel
|
||||
if( minp.y < -64 or minp.y > 0) then
|
||||
return;
|
||||
end
|
||||
|
||||
local heightmap = minetest.get_mapgen_object('heightmap');
|
||||
if( not( heightmap )) then
|
||||
return;
|
||||
end
|
||||
|
||||
-- place a ship on water if possible; do this with the given probability
|
||||
if( math.random(1,100)<ships_on_mapgen.probability_per_mapchunk ) then
|
||||
-- I have accidently used the building spawner instead of a chest when building the
|
||||
-- rafts. But that can easily be corrected here.
|
||||
local replacements = {{'handle_schematics:build','default:chest'}};
|
||||
-- choose a random ship
|
||||
local building = ships_on_mapgen.schematics[ math.random(1,#ships_on_mapgen.schematics) ];
|
||||
-- the boat file uses strange blocks not occouring in default
|
||||
if( building.scm == "boat" ) then
|
||||
replacements = {
|
||||
{'color:orange', 'default:wood'},
|
||||
{'color:white', 'wool:white'},
|
||||
{'color:black', 'wool:black'}};
|
||||
elseif( math.random(1,3)>1) then
|
||||
-- colored sails can make the ships more intresting
|
||||
local colors = {"white", "white", "yellow", "grey", "black", "brown", "dark_green"};
|
||||
table.insert( replacements, {"cottages:wool", "wool:"..colors[math.random(1,#colors)]});
|
||||
else
|
||||
-- not all ships have sails set
|
||||
table.insert( replacements, {"cottages:wool", "air"});
|
||||
end
|
||||
local success = handle_schematics.place_schematic_on_flat_land( heightmap, minp, maxp,
|
||||
building.sizex, building.sizez, -100, building.yoff-1,
|
||||
3, 3, 0, 0, -- margin: front, back, right, left
|
||||
ships_on_mapgen.mts_path..building.scm, --..".mts",
|
||||
replacements,
|
||||
building.yoff,
|
||||
building.orients[1],
|
||||
building
|
||||
);
|
||||
end
|
||||
end);
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue