fixed rotation bug regarding build_chest

This commit is contained in:
Sokomine 2015-04-24 17:32:32 +02:00
parent 0cd759ab33
commit 13410cf181
2 changed files with 14 additions and 7 deletions

View File

@ -124,10 +124,12 @@ end
-- this function makes sure that the building will always extend to the right and in front of the build chest
handle_schematics.translate_param2_to_rotation = function( param2, mirror, start_pos, orig_max, rotated, burried, orients )
handle_schematics.translate_param2_to_rotation = function( param2, mirror, start_pos, orig_max, rotated, burried, orients, yoff )
-- mg_villages stores available rotations of buildings in orients={0,1,2,3] format
if( orients and #orients and orients[1]~=0) then
-- reset rotated - else we'd apply it twice
rotated = 0;
if( orients[1]==1 ) then
rotated = rotated + 90;
elseif( orients[1]==2 ) then
@ -135,7 +137,7 @@ handle_schematics.translate_param2_to_rotation = function( param2, mirror, start
elseif( orients[1]==3 ) then
rotated = rotated + 270;
end
if( rotated > 360 ) then
if( rotated >= 360 ) then
rotated = rotated % 360;
end
end
@ -148,7 +150,7 @@ handle_schematics.translate_param2_to_rotation = function( param2, mirror, start
end
-- the building may have a cellar or something alike
if( burried > 0 ) then
if( burried and burried ~= 0 and yoff == nil ) then
start_pos.y = start_pos.y - burried;
end
@ -220,7 +222,8 @@ build_chest.get_start_pos = function( pos )
-- make sure the building always extends forward and to the right of the player
local param2_rotated = handle_schematics.translate_param2_to_rotation( node.param2, mirror, start_pos,
selected_building.size, selected_building.rotated, selected_building.burried, selected_building.orients );
selected_building.size, selected_building.rotated, selected_building.burried, selected_building.orients,
selected_building.yoff );
-- save the data for later removal/improvement of the building in the chest
meta:set_string( 'start_pos', minetest.serialize( param2_rotated.start_pos ));

View File

@ -689,7 +689,6 @@ mg_villages.place_building_from_file = function( start_pos, end_pos, building_na
binfo.sizex = binfo.size.x;
binfo.sizez = binfo.size.z;
binfo.ysize = binfo.size.y;
-- binfo.rotated and binfo.burried are unused
-- this value has already been taken care of when determining start_pos
binfo.yoff = 0;
@ -698,8 +697,7 @@ mg_villages.place_building_from_file = function( start_pos, end_pos, building_na
-- this is relevant for mirroring operations
binfo.axis = axis;
-- start_pos contains already *.x,*.y,*.z of the desired start position;
-- translate rotation from 0,90,180,270 to 0,1,2,3
if( not( rotate ) or rotate=="0" ) then
start_pos.brotate = 0;
elseif( rotate=="90" ) then
@ -709,6 +707,12 @@ mg_villages.place_building_from_file = function( start_pos, end_pos, building_na
elseif( rotate=="270" ) then
start_pos.brotate = 3;
end
if( start_pos.brotate > 3 ) then
start_pos.brotate = start_pos.brotate % 4;
end
-- determine the size of the bulding from the place we assigned to it...
start_pos.bsizex = math.abs(end_pos.x - start_pos.x)+1;
start_pos.bsizez = math.abs(end_pos.z - start_pos.z)+1;