(07-08-2015, 10:25 PM)Romulator Wrote: Name all your ScriptAreas where the parts could potentially spawn Area_ followed by 1 to 6 (Area_1, Area_2, Area_3 ... Area_6).
Then try this:
void OnStart()
{
CreateEntityAtArea("<name_of_part_1>", "entity.ent", "Area_"+RandInt(1, 2), false);
CreateEntityAtArea("<name_of_part_2>", "entity.ent", "Area_"+RandInt(3, 4), false);
CreateEntityAtArea("<name_of_part_3>", "entity.ent", "Area_"+RandInt(5, 6), false);
}
However:
1. Don't have your parts already placed in the level. This will create them. If you have two doors both called "door" in game, the game crashes because it does not know which door is which. Make sure to rename the first string to suit your code as well.
2. "entity.ent" should be changed to whatever the entity is that your part will be using.
If the game crashes with an "Expected ;" error, place it after the RandInt() but before the comma in each routine. I keep forgetting if it is required when calling it within a line itself.
Thanks!!
Only, 1 thing looks strange.
"Area_"+RandInt(1, 2), false);
what do you exactly mean by (1, 2)
The first thing I thought was the area 1,2
But where is it stated that it is going to spawn on one of those palce "50%"
CreateEntityAtArea("<name_of_part_1>", "entity.ent", "Area_"+RandInt(1, 2), false);
if I look to this script, It creates "entity.ent" (what basically is, a part I am going to use)
on the Area_ (basically 1, or 2. +Randint (1, 2) <Will that tell the script to spawn OR 1, or 2?!
So or it is going to spawn area_1 or area_2
So does that state the 50%?!
Thanks
(07-08-2015, 10:25 PM)Romulator Wrote: Name all your ScriptAreas where the parts could potentially spawn Area_ followed by 1 to 6 (Area_1, Area_2, Area_3 ... Area_6).
Then try this:
void OnStart()
{
CreateEntityAtArea("<name_of_part_1>", "entity.ent", "Area_"+RandInt(1, 2), false);
CreateEntityAtArea("<name_of_part_2>", "entity.ent", "Area_"+RandInt(3, 4), false);
CreateEntityAtArea("<name_of_part_3>", "entity.ent", "Area_"+RandInt(5, 6), false);
}
However:
1. Don't have your parts already placed in the level. This will create them. If you have two doors both called "door" in game, the game crashes because it does not know which door is which. Make sure to rename the first string to suit your code as well.
2. "entity.ent" should be changed to whatever the entity is that your part will be using.
If the game crashes with an "Expected ;" error, place it after the RandInt() but before the comma in each routine. I keep forgetting if it is required when calling it within a line itself.
Thanks!!
Only, 1 thing looks strange.
"Area_"+RandInt(1, 2), false);
what do you exactly mean by (1, 2)
The first thing I thought was the area 1,2
But where is it stated that it is going to spawn on one of those palce "50%"
CreateEntityAtArea("<name_of_part_1>", "entity.ent", "Area_"+RandInt(1, 2), false);
if I look to this script, It creates "entity.ent" (what basically is, a part I am going to use)
on the Area_ (basically 1, or 2. +Randint (1, 2) <Will that tell the script to spawn OR 1, or 2?!
So or it is going to spawn area_1 or area_2
So does that state the 50%?!
Thanks