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
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


Messages In This Thread
Problem with the CreateEntityAtArea - by Red - 01-14-2013, 07:00 PM
RE: Problem with the CreateEntityAtArea - by Red - 01-14-2013, 07:24 PM
RE: Problem with the CreateEntityAtArea - by TheGreatCthulhu - 01-14-2013, 11:20 PM
RE: Problem with the CreateEntityAtArea - by Red - 01-14-2013, 08:07 PM
RE: Problem with the CreateEntityAtArea - by Red - 01-15-2013, 07:02 AM



Users browsing this thread: 1 Guest(s)