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


Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with the CreateEntityAtArea
Red Offline
Posting Freak

Posts: 1,757
Threads: 49
Joined: Feb 2012
Reputation: 54
#1
Problem with the CreateEntityAtArea

Why this script doesn't work?
The sound works and stuff but the freaking Entity doesn't appear!

PHP Code: (Select All)
void OnStart()
{

       
AddUseItemCallback("place""A""B","C"false);
}



void C(string &in asItemstring &in asEntity)
{

    
RemoveItem(asItem);
    
CreateEntityAtArea(asItemasItemasEntitytrue);
    
PlaySoundAtEntity("s""derb.snt""B"0false);
    } 
(This post was last modified: 01-15-2013, 05:26 PM by Red.)
01-14-2013, 07:00 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#2
RE: Problem with the CreateEntityAtArea

Instead that CreateEntity thing, use:

CreateEntityAtArea(string& asEntityName, string& asEntityFile, string& asAreaName, bool abFullGameSave);



Ergo:

CreateEntityAtArea("Nameofentity", "Entity.ent", "Areaname", true);

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
01-14-2013, 07:15 PM
Find
Red Offline
Posting Freak

Posts: 1,757
Threads: 49
Joined: Feb 2012
Reputation: 54
#3
RE: Problem with the CreateEntityAtArea

(01-14-2013, 07:15 PM)The chaser Wrote: Instead that CreateEntity thing, use:

CreateEntityAtArea(string& asEntityName, string& asEntityFile, string& asAreaName, bool abFullGameSave);



Ergo:

CreateEntityAtArea("Nameofentity", "Entity.ent", "Areaname", true);
The upper way doesn't work and the below way is not what i really was looking for.
01-14-2013, 07:24 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#4
RE: Problem with the CreateEntityAtArea

The CreateEntityAtArea is what you did, it was what you were searching (or that I think :$)

You can have another item inactive and then just SetEntityActive.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
01-14-2013, 07:54 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#5
RE: Problem with the CreateEntityAtArea

CreateEntityAtArea loads an ENT file at the area specified. It is not for duplicating already existing entities.

Tutorials: From Noob to Pro
01-14-2013, 07:55 PM
Website Find
Red Offline
Posting Freak

Posts: 1,757
Threads: 49
Joined: Feb 2012
Reputation: 54
#6
RE: Problem with the CreateEntityAtArea

(01-14-2013, 07:55 PM)Your Computer Wrote: CreateEntityAtArea loads an ENT file at the area specified. It is not for duplicating already existing entities.
So the same item has to exist already in the inventory to work? It has to
be picked up in other level? So complicated.
(This post was last modified: 01-14-2013, 08:16 PM by Red.)
01-14-2013, 08:07 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#7
RE: Problem with the CreateEntityAtArea

(01-14-2013, 08:07 PM)Pyöveli Wrote: So the same item has to exist already in the inventory to work? It has to
be picked up in other level? So complicated.

That has no direct relation to CreateEntityAtArea.

Tutorials: From Noob to Pro
01-14-2013, 08:40 PM
Website Find
darksky Offline
Member

Posts: 52
Threads: 8
Joined: Nov 2012
Reputation: 2
#8
RE: Problem with the CreateEntityAtArea

maybe you should explain what you want to do
01-14-2013, 10:24 PM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#9
RE: Problem with the CreateEntityAtArea

(01-14-2013, 07:00 PM)Pyöveli Wrote: Why this script doesn't work?
The sound works and stuff but the freaking Entity doesn't appear!

It doesn't work because you obviously have absolutely no idea what you are doing there (no disrespect intended).

First, in the editor and in code, don't name your items and entities with names like "A" and "B". Give them some names that are more descriptive, so that we (and you) can see from the code what is going on, and what you're trying to do.

"C" is also a poor name for a function.

Say you renamed your entities and the function somewhere along these lines (forfeiting about your actual game elements for the moment):
"A" --> "Acid_Bottle"
"B" --> "Oganic_Web"
"C" --> "OnUseAcid"

Also, that "place" parameter is just an internal name of the callback, which can be used by another predefined function to remove the callback at some different point in the script, so, in your case, it doesn't really matter what's written there.

You'll agree that
PHP Code: (Select All)
AddUseItemCallback("id.useacid""Acid_Bottle""Oganic_Web""OnUseAcid"false); 
is much more comprehensible than
PHP Code: (Select All)
AddUseItemCallback("place""A""B","C"false);  // what's A, B, C? o.O 

Now, this is why CreateEntityAtArea(asItem, asItem, asEntity, true) doesn't work. Let's go back to what The chaser told you:

(01-14-2013, 07:24 PM)Pyöveli Wrote:
(01-14-2013, 07:15 PM)The chaser Wrote: Instead that CreateEntity thing, use:

CreateEntityAtArea(string& asEntityName, string& asEntityFile, string& asAreaName, bool abFullGameSave);



Ergo:

CreateEntityAtArea("Nameofentity", "Entity.ent", "Areaname", true);
The upper way doesn't work and the below way is not what i really was looking for.

The "upper way" doesn't work because it's not a way, it's the declaration of the CreateEntityAtArea() function, which tells you, if you know how to read it, how the function is used, and what each part of it means. The "below way" demonstrates how to actually use the function in code, but you have to replace those strings with the names that correspond to the ones used on your map.

Looking at the "below way", this is what each of the parameters mean, and what you need to replace them with:
  • Nameofentity - this is the internal name, used by the game, for the entity that is to be created. You pick it yourself. It is similar to the name each entity has in the editor - there should be no two entities with the same name. Replace it with whatever you find suitable.
  • Entity.ent - this is the file which defines the entity, and the game will use this file to figure out which entity is supposed to be created. Replace it with the name of the entity file you want to use (monster, or some other entity), followed by the .ent extension.
  • Areaname - defines at which area the entity will spawn; obviously, there needs to be a corresponding area placed in the level editor. Replace it with the name of your script area.
  • true - just means that the state of the entity should be saved on game exit, leave it as is.

Now, with all that in mind, look what you did:
PHP Code: (Select All)
CreateEntityAtArea(asItemasItemasEntitytrue); 

Here, the asItem parameter contains the name of the item you used, and asEntity contains the name of entity on which the item was used. So, you've passed along the item name as the internal ID for the new entity, then you again passed the item name in place of the entity file, and then you place the name of the use-target instead of an area where the entity is supposed to be created!

In my example with the Acid_Bottle and Organic_Web, you basically told that function:
Create entity "Acid_Bottle" at area "Organic_Web", and give it internal name "Acid_Bottle". This can't be what you wanted to do, and the script wouldn't know what to do with it anyway.

So go replace the parameter values as explained. If you can't figure it out yourself, come back here and explain in more detail what is it that you're trying to do, and tell us the names of the items and entities involved.
(This post was last modified: 01-14-2013, 11:24 PM by TheGreatCthulhu.)
01-14-2013, 11:20 PM
Find
Red Offline
Posting Freak

Posts: 1,757
Threads: 49
Joined: Feb 2012
Reputation: 54
#10
RE: Problem with the CreateEntityAtArea

The script is just an example. I am not currently using it in any cs. You don't need to explain how to use the function. I already know.
It seems most of you misunderstood my point. And the issue has been already solved thanks to YourComputer in post #5.

But still, thanks to everyone who tried to help.
(This post was last modified: 01-15-2013, 05:26 PM by Red.)
01-15-2013, 07:02 AM
Find




Users browsing this thread: 3 Guest(s)