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
CreateEntityAtArea problem
Rapture Offline
Posting Freak

Posts: 1,078
Threads: 79
Joined: May 2011
Reputation: 30
#1
CreateEntityAtArea problem

Is this another one of the functions that need some special need like
SetSwingDoorClosed
because you can't close a door without using
AddPropImpulse

I'm trying to do loops (gonna figure it out myself hopefully). I'm testing to create some pots that will be made every 1 second for 10 times, and apparently nothing is being created. I tested out the sound, and I it works correctly.

    for(int i = 0; i <10; i++)
        AddTimer("T", i, "TimerFunction");
Copied the code from wiki.frictional, couldn't find any loop examples anywhere else or any ones I want.
void TimerFunction(string &in asTimer)
{
    PlaySoundAtEntity("scare", "react_scare.snt", "Player", 0, false);
    CreateEntityAtArea("Create", "vase01.ent", "ScriptArea_1", false);
}
So can I not create entities at areas? I would find this very sad for my custom story Sad
08-03-2011, 03:27 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#2
RE: CreateEntityAtArea problem

Try this:

void OnStart()
{
     SetLocalVarInt("Var01", 0); // # of pots made check
     Func01(); // looping function
}
void Func01()
{
     AddTimer("", 1, "Func02");
}
void Func02(string &in asTimer)
{
     if (GetLocalVarInt("Var01") < 11)
     {
          int x = GetLocalVarInt("Var01");
          x = x + 1;
          SetLocalVarInt("Var01", x); // I'm just using one way, there are many other ways to do it
          PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
          CreateEntityAtArea("Create", "vase01.ent", "ScriptArea_1", false);
          Func01();
     }
}

I was able to implement rocks to be created at random times at random areas and random rock sizes (out of 2). After the 100th or so rock does it start lagging. xD

(This post was last modified: 08-03-2011, 03:51 AM by Kyle.)
08-03-2011, 03:49 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#3
RE: CreateEntityAtArea problem

Rapture, your code should work. Perhaps the entity needs a unique name, though, so try:

    //Change your first bit of code to this
for(int i = 0; i <10; i++)
AddTimer("T"+i, i, "TimerFunction");

//Change your timer callback to this
void TimerFunction(string &in asTimer)
{
        AddDebugMessage("Creating object Create"+asTimer,false);
    PlaySoundAtEntity("scare", "react_scare.snt", "Player", 0, false);
    CreateEntityAtArea("Create"+asTimer, "vase01.ent", "ScriptArea_1", false);
}

Though note that this will create all the vases at one location. You should create multiple script areas and do the following:
//Change your first bit of code to this
for(int i = 0; i <10; i++)
AddTimer("_"+(i+1), i, "TimerFunction");

//Change your timer callback to this
void TimerFunction(string &in asTimer)
{
        AddDebugMessage("Creating object Create"+asTimer,false);
    PlaySoundAtEntity("scare", "react_scare.snt", "Player", 0, false);
    CreateEntityAtArea("Create"+asTimer, "vase01.ent", "ScriptArea"+asTimer, false);
}
(This post was last modified: 08-03-2011, 09:30 PM by Apjjm.)
08-03-2011, 09:25 PM
Find




Users browsing this thread: 1 Guest(s)