Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RandInt ?!
Amnesiaplayer Offline
Senior Member

Posts: 539
Threads: 105
Joined: Jun 2014
Reputation: 0
#16
RE: RandInt ?!

(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:
PHP Code: (Select All)
void OnStart()
{
CreateEntityAtArea("<name_of_part_1>""entity.ent""Area_"+RandInt(12), false);
CreateEntityAtArea("<name_of_part_2>""entity.ent""Area_"+RandInt(34), false);
CreateEntityAtArea("<name_of_part_3>""entity.ent""Area_"+RandInt(56), 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 Big Grin

(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:
PHP Code: (Select All)
void OnStart()
{
CreateEntityAtArea("<name_of_part_1>""entity.ent""Area_"+RandInt(12), false);
CreateEntityAtArea("<name_of_part_2>""entity.ent""Area_"+RandInt(34), false);
CreateEntityAtArea("<name_of_part_3>""entity.ent""Area_"+RandInt(56), 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 Big Grin
(This post was last modified: 07-08-2015, 10:33 PM by Amnesiaplayer.)
07-08-2015, 10:33 PM
Find


Messages In This Thread
RandInt ?! - by Amnesiaplayer - 07-05-2015, 08:01 PM
RE: MudBox Export Issue - by Traggey - 07-05-2015, 09:35 PM
RE: MudBox Export Issue - by Amnesiaplayer - 07-05-2015, 09:46 PM
RE: MudBox Export Issue - by Traggey - 07-05-2015, 10:00 PM
RE: MudBox Export Issue - by Amnesiaplayer - 07-05-2015, 10:04 PM
RE: MudBox Export Issue - by Traggey - 07-05-2015, 10:06 PM
RE: MudBox Export Issue - by Amnesiaplayer - 07-05-2015, 10:15 PM
RE: MudBox Export Issue - by Daemian - 07-06-2015, 01:38 PM
RE: MudBox Export Issue - by Amnesiaplayer - 07-06-2015, 01:59 PM
RE: RandInt ?! - by Daemian - 07-07-2015, 08:29 PM
RE: RandInt ?! - by Amnesiaplayer - 07-08-2015, 09:14 PM
RE: RandInt ?! - by Rahmerh - 07-08-2015, 09:16 PM
RE: RandInt ?! - by DnALANGE - 07-08-2015, 09:17 PM
RE: RandInt ?! - by Amnesiaplayer - 07-08-2015, 09:42 PM
RE: RandInt ?! - by Romulator - 07-08-2015, 10:25 PM
RE: RandInt ?! - by Amnesiaplayer - 07-08-2015, 10:33 PM
RE: RandInt ?! - by Romulator - 07-08-2015, 10:39 PM
RE: RandInt ?! - by Amnesiaplayer - 07-08-2015, 10:44 PM
RE: RandInt ?! - by Mudbill - 07-09-2015, 12:54 PM



Users browsing this thread: 1 Guest(s)