provide diffrent positions in front of the house

This commit is contained in:
Sokomine 2017-06-18 20:34:19 +02:00
parent 244ab3fca5
commit 91d7c42bba

View File

@ -130,22 +130,26 @@ end
-- pos has to contain information about the building - o (orientation), bsizex and bsizez
-- this function returns a position in front of the building, with the building stretching equally to the right and left
-- (useful for mobs who want to leave/enter the plot)
handle_schematics.get_pos_in_front_of_house = function( pos )
-- bed_nr can be used to assign diffrent spawn points to mobs in diffrent beds
handle_schematics.get_pos_in_front_of_house = function( pos, bed_nr )
if( not( mob_nr )) then
mob_nr = 0;
end
local p = {x=pos.x, y=pos.y+1, z=pos.z};
if( pos.o == 0 ) then
p.x = p.x - 1;
p.z = p.z + pos.bsizez - 1;
p.z = p.z - math.floor(pos.bsizex/2+0.5);
p.z = p.z - math.floor(pos.bsizex/2+0.5) - bed_nr;
elseif( pos.o == 2 ) then
p.x = p.x + pos.bsizex;
p.z = p.z + math.floor(pos.bsizex/2+0.5);
p.z = p.z + math.floor(pos.bsizex/2+0.5) + bed_nr;
elseif( pos.o == 1 ) then
p.z = p.z + pos.bsizez;
p.x = p.x + pos.bsizex - 1;
p.x = p.x - math.floor(pos.bsizez/2+0.5);
p.x = p.x - math.floor(pos.bsizez/2+0.5) - bed_nr;
elseif( pos.o == 3 ) then
p.z = p.z - 1;
p.x = p.x + math.floor(pos.bsizez/2+0.5);
p.x = p.x + math.floor(pos.bsizez/2+0.5) + bed_nr;
end
return p;
end