Harry
Member
|
Dynamically created objects
Is object created in game by objCreate function automatically stored in Memx containers for objects for example to Items container? How can I get it to single Item item; variable? Bu id or something?
(This post was last modified: 11-03-2010 08:40 PM by Harry.)
|
|
11-03-2010 08:40 PM |
|
Esenthel
Administrator
|
RE: Dynamically created objects
yes, it gets stored, unless it gets flushed to disk (please check comments on objCreate)
you should use objCreateNear if you want to access created object as it returns pointer to the object
|
|
11-03-2010 10:01 PM |
|
Harry
Member
|
RE: Dynamically created objects
Ok, thanks. When I'll have got free time I'll check this. But now I use this code:
Code:
Game::ObjParams &obj=*Game::Objs(itemPath); // get weapon object parameters
Game::World.objCreate(obj,Matrix(obj.scale(),waypoint->point(targetNumber).pos)); // create new object
item=&Items[Items.validElms()-1]; // save last item from container to Item variable
Is it ok? Or has it any disadvantages?
|
|
11-04-2010 05:15 PM |
|
Esenthel
Administrator
|
RE: Dynamically created objects
that's bad
you should use objCreateNear
|
|
11-04-2010 05:54 PM |
|
Harry
Member
|
RE: Dynamically created objects
I use objCreateNear and asign result to Game::Obj variable, but I can't assign it to Item. Is it possible?
|
|
11-06-2010 11:11 PM |
|
Driklyn
Member
|
RE: Dynamically created objects
Code:
Item *item = CAST(Item, obj);
This should work I believe.
|
|
11-07-2010 03:35 AM |
|
Harry
Member
|
RE: Dynamically created objects
Yes it works, thank you.
|
|
11-07-2010 11:53 AM |
|
Harry
Member
|
RE: Dynamically created objects
One more question. How can I check that I have grabbed item on the list or in slot. I don't mean any object but the specific one. For example I created object which is one of targets in mission, and I want check if it is in my inventory.
|
|
11-12-2010 06:34 PM |
|
Esenthel
Administrator
|
RE: Dynamically created objects
add a unique parameter to it.
|
|
11-12-2010 07:10 PM |
|
Harry
Member
|
RE: Dynamically created objects
Ok, I thought that there is another way.
|
|
11-12-2010 08:47 PM |
|