Pshyched
Member
Posts: 130
Threads: 21
Joined: Nov 2012
Reputation:
5
|
Why is this not functioning correctly?
Okay, I am trying something new in the editor, and I am wonder why this is not working..
void ReplaceOrb(string &in AsParent, string &in AsChild, int &in AlState) { AddTimer("Wait", 0.5, "ReplaceOrbTimer"); AddTimer("Replace", 1.0, "ReplaceOrbTimer"); } void ReplaceOrbTimer(string &in asTimer) { string x = asTimer; if (x == "Wait") { SetEntityActive("RealmOrb", false); SetMessage("Messages", "DropOrb", 0); } if (x == "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?
|
|
06-30-2013, 09:38 AM |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
RE: Why is this not functioning correctly?
No you can't. Every thing ends with _1 and the number changes as you copy it.
"Veni, vidi, vici."
"I came, I saw, I conquered."
|
|
06-30-2013, 11:58 AM |
|
Pshyched
Member
Posts: 130
Threads: 21
Joined: Nov 2012
Reputation:
5
|
RE: Why is this not functioning correctly?
Any idea on how I would get around this?
|
|
06-30-2013, 12:01 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: Why is this not functioning correctly?
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.
|
|
06-30-2013, 12:11 PM |
|
Pshyched
Member
Posts: 130
Threads: 21
Joined: Nov 2012
Reputation:
5
|
RE: Why is this not functioning correctly?
Uhhh, How would I implement that?
|
|
06-30-2013, 01:27 PM |
|
Wapez
Senior Member
Posts: 360
Threads: 37
Joined: Mar 2012
Reputation:
19
|
RE: Why is this not functioning correctly?
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.
(This post was last modified: 06-30-2013, 04:32 PM by Wapez.)
|
|
06-30-2013, 04:26 PM |
|
Pshyched
Member
Posts: 130
Threads: 21
Joined: Nov 2012
Reputation:
5
|
RE: Why is this not functioning correctly?
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.
|
|
06-30-2013, 04:47 PM |
|
Wapez
Senior Member
Posts: 360
Threads: 37
Joined: Mar 2012
Reputation:
19
|
RE: Why is this not functioning correctly?
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);
|
|
06-30-2013, 06:26 PM |
|
|