Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (TipmyPip, AndrewAMD, dBc, clonman), 18,643 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[help]How to access user data by a engine object pointer #278329
07/13/09 07:19
07/13/09 07:19
Joined: May 2009
Posts: 7
micmoc Offline OP
Newbie
micmoc  Offline OP
Newbie

Joined: May 2009
Posts: 7
I need using some user data (like ItemIndex, ItemType, Attribute...etc)which linked to an entity. Now I get the Entity's pointer, how can I access those data?

I try to do this:
Using a struct collect the values,
Code:
typedef struct Item
{
    int iIndex;
    int iType;
    int iMaxEffection;
    int iMinEffection;
    int iEquipLimit;
    ...
    STRING *pszItemName;
    STRING *pszItmeText;
    ENTITY *pItemEnt;
}T_Item;


and then create a Item implementation in game,
use c_trace get the target pointer what I touched,
now I want to show the target name, how can I using the pointer(T_Item->pItemEnt) to get other struct members (T_Item->pszItemName)?

Thanks to read.

Re: [help]How to access user data by a engine object pointer [Re: micmoc] #278333
07/13/09 07:39
07/13/09 07:39
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
u mean here u have many entities. so u should create an array of the struct instead. and access using the index to differentiate between each entity.

cause from your coded, the pointer T_Item->pItemEnt is the same structure as T_Item->pszItemName. both are members of same structure.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: [help]How to access user data by a engine object pointer [Re: delinkx] #278339
07/13/09 08:19
07/13/09 08:19
Joined: May 2009
Posts: 7
micmoc Offline OP
Newbie
micmoc  Offline OP
Newbie

Joined: May 2009
Posts: 7
Thanks delinkx.
yep, I got the pointer of the entity, and I don't know which T_Item instance contains it, I want to find the entity's parent struct inst and using other members in it.

An array of struct to collect entities is a member of higher level object "Item Collecter". I mean I catch a pointer, use it drawing a Item struct out of items and don't want ask everyone "Is this pointer yours?"

Last edited by micmoc; 07/13/09 08:20.
Re: [help]How to access user data by a engine object pointer [Re: micmoc] #278341
07/13/09 08:33
07/13/09 08:33
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
The best way Ive found is, when adding the entity to the struct inst,
store a pointer to the struct inst in one of the entity skills,
or its "reference" number as it is stored in the "item collector".

I sometimes store a VOIDed pointer to the struct inst in the
"entity.parant" pointer too. Only if not using templates for anything.

That way T_ITEM can directly access ENTITY with T_ITEM->pItemEnt
and ENTITY can directly access T_ITEM with (T_Item*)ENTITY->parent


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: [help]How to access user data by a engine object pointer [Re: EvilSOB] #278394
07/13/09 13:32
07/13/09 13:32
Joined: May 2009
Posts: 7
micmoc Offline OP
Newbie
micmoc  Offline OP
Newbie

Joined: May 2009
Posts: 7
Thanks EvilSOB.
I forgot the skills...


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1