added Place()-function to sea weed

issue1247
David Dormagen 2013-07-11 21:07:24 +02:00 committed by Sven Eberhardt
parent fb1ee2f88f
commit fe04a0fe79
1 changed files with 18 additions and 0 deletions

View File

@ -2,6 +2,24 @@
#include Library_Plant
func Place(int amount, proplist rectangle, proplist settings)
{
var max_tries = 2 * amount;
var loc_area = nil;
if (rectangle) loc_area = Loc_InRect(rectangle);
while ((amount > 0) && (--max_tries > 0))
{
var spot = FindLocation(Loc_Material("Water"), Loc_Wall(CNAT_Bottom), loc_area);
if (!spot) continue;
var f = CreateObject(this, spot.x, spot.y, NO_OWNER);
--amount;
}
return true;
}
private func Initialize()
{
SetAction("Sway");