Category: Objects
/ Creation
Since engine version: 1.0 OC
PlaceObjects
Description
Creates the specified number of objects in the specified target rectangle and target material (optional). Returns the number of iterations or -1 if creation has failed.
Syntax
int PlaceObjects(id definition, int amount, string material_name, int x, int y, int width, int height, bool on_surface, bool no_stuck);
Parameters
- definition:
- ID of the object to be created
- amount:
- Count of objects to be created
- material_name:
- Material in which object are to be created. This can be a material name or a string as follows:
material_index Create in "GBackSolid" Objects are created in solid material. Also see GBackSolid(). "GBackSemiSolid" Objects are created in solid or liquid material. Also see GBackSemiSolid(). "GBackLiquid" Objects are created in liquid material. Also see GBackLiquid(). "GBackSky" Objects are created in mid-air. Also see GBackSky(). - x:
- [opt] Left boundary coordinate of the target rectangle (x coordinate).
- y:
- [opt] Top boundary coordinate of the target rectangle (y coordinate).
- width:
- [opt] Width of the target rectangle. If not specified, the right landscape boundary.
- height:
- [opt] Height of the target rectangle. If not specified, the bottom landscape boundary.
- on_surface:
- [opt] If
true
, all objects will be created above the upper surface of the specified material (this might be outside the target rectangle). - no_stuck:
- [opt] If
true
, placement will not ensure that objects are in solid material. This is needed e.g. when placing objects in liquids.
Remark
If there is only very little of the target material present in the landscape, placement calculation will take longer.
However, endless retry loops are avoided.
However, endless retry loops are avoided.
Examples
PlaceObjects(Loam,20,"Earth",100,0,200)
Create 20 chunks of loam in earth within the coordinates 100,0 and 200,LandscapeHeight().
PlaceObjects(Fish,10,"GBackLiquid",0,0,0,LandscapeHeight()/2,0,1);
Creates a total of 10 fishes in all liquids found in the upper half of the landscape.
See also: CreateObject