Frictional Games Forum (read-only)

Full Version: Why is this not functioning correctly?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okay, I am trying something new in the editor, and I am wonder why this is not working..

PHP Code:
    void ReplaceOrb(string &in AsParentstring &in AsChildint &in AlState)
    {
        
AddTimer("Wait"0.5"ReplaceOrbTimer");
        
AddTimer("Replace"1.0"ReplaceOrbTimer");
    }
    
void ReplaceOrbTimer(string &in asTimer)
    {
        
string x asTimer;
        if (
== "Wait")
        {
            
SetEntityActive("RealmOrb"false);
            
SetMessage("Messages""DropOrb"0);
        }
        if (
== "Replace")
        {
            
CreateEntityAtArea("RealmOrb""orb_grab.ent""ScriptArea_1"true);
        }
    } 

Everything runs smoothly in game, but as it creates another entity under the name of "RealmOrb" i think its creating it as "RealmOrb_1" so the rest of the scripting remains useless. Is there a way to make it not change its name? As you can see, I made a wait timer so it would try not too, But ofcourse, It wont work because Im only making the Previous Entity Inactive. I don't think there is a RemoveEntity script function within the game. Unless I am mistaken?
No you can't. Every thing ends with _1 and the number changes as you copy it.
Any idea on how I would get around this?
I doubt the game is renaming the newly-created entity but that the game is searching for the entity in some kind of order-by-creation list, therefore the one in the map first is the one found first when calling SetEntityActive. Try using a local map variable of type int to keep track of the number of orbs created, so that you can increment the name of the orb.
Uhhh, How would I implement that?
It seems as you already have a "RealmOrb" in the map, and therefore you set it unactive with the "wait" timer. Since you don't REMOVE the first orb, you just set it to UNACTIVE, it remains in the map. The next "RealmOrb" put in the map, will then be renamed to "RealmOrb_1", since an entity with the name "RealmOrb" is already existing.

Why not just name the new orb (That you CREATE with the "replace" timer) "RealmOrb_1", and coordinate your script after that?

Or just rename the first orb to something else. That way the orb you CREATE won't change names.
I need to have it so if the player drops the RealmOrb, it reverts back to its original script. But the RealmOrb is also used in other scripts too. Is there a way to set it as a Variable or something, so I can just set and update the variable to my scripts. That would make things 100x easier.
Instead of creating a new orb, you can simply reset the original one using the function below, returning it to it's original position and state.

void ResetProp(string& asName);