Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (Quad, AndrewAMD), 1,007 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to add entity properties #209834
06/06/08 05:07
06/06/08 05:07
Joined: Jun 2008
Posts: 91
C
Coisox Offline OP
Junior Member
Coisox  Offline OP
Junior Member
C

Joined: Jun 2008
Posts: 91
ENTITY* myBall;
ENTITY* hisBall;

I want to add custom property into ENTITY, let say "power" so I can write:

myBall.power = 3;
hisBall.power = 10;

How?

Re: How to add entity properties [Re: Coisox] #209841
06/06/08 07:25
06/06/08 07:25
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Theoretically, you could extent the Entity datastructure in atypes.h, but this is not recommended. Try encapsulating further attributes in a struct that is hinged into an entity skill (write the pointer into a skill and retrieve it during runtime to access it).

OR: make a datastructure and hinge the entity in it wink

Re: How to add entity properties [Re: Coisox] #209846
06/06/08 07:48
06/06/08 07:48

M
mercuryus
Unregistered
mercuryus
Unregistered
M



Did you know about the already defined skills?
You can redefine them to your own names.
There are already 100 skills to use for such needs.

With your example you would make a definition like this:

#define power skill1

Then each ENTITY will have this property (you can access with this name) myBall.power, hisBall.power, ...



Re: How to add entity properties [Re: ] #209847
06/06/08 08:18
06/06/08 08:18
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Ah, yes ^^ You should use skills as long as you don't need such fancy stuff wink

Last edited by HeelX; 06/06/08 08:18.
Re: How to add entity properties [Re: HeelX] #209891
06/06/08 13:10
06/06/08 13:10
Joined: Jun 2008
Posts: 91
C
Coisox Offline OP
Junior Member
Coisox  Offline OP
Junior Member
C

Joined: Jun 2008
Posts: 91
Thank you guys. I didn't know about skills. Because I only read the Lite-C Workshops. And I open the "help" inside Lite-C when I want to look for something.

Where can I find the listing of all properties for all object type?

Re: How to add entity properties [Re: Coisox] #209896
06/06/08 13:40
06/06/08 13:40
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Manual:



all their properties are listed


3333333333
Re: How to add entity properties [Re: HeelX] #210544
06/11/08 12:11
06/11/08 12:11
Joined: Jan 2002
Posts: 300
Usa
Rich Offline
Senior Member
Rich  Offline
Senior Member

Joined: Jan 2002
Posts: 300
Usa
Originally Posted By: HeelX
Theoretically, you could extent the Entity datastructure in atypes.h, but this is not recommended. Try encapsulating further attributes in a struct that is hinged into an entity skill (write the pointer into a skill and retrieve it during runtime to access it).

OR: make a datastructure and hinge the entity in it wink


Hi, Sorry to jump in but this was a question I was wondering about as well.

I knew about the skills but I find I may need to store more data (list of object, entities, ect, even if I ended up not needing to do it I would like to learn) and wanted to extend the entity properties. Could you maybe describe how this is done in a brief way or point me to a source on how I can hinge a struct to the ENTITY struct? Sorry I'm still learning all of this, Thanks so much.

Re: How to add entity properties [Re: Rich] #210574
06/11/08 15:39
06/11/08 15:39
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline
Member
Fenriswolf  Offline
Member
F

Joined: Jan 2007
Posts: 221
You could do it like the following:
Code:
/* a pointer to the I_WANT_MORE_SKILLS struct will be saved in this entity skill */ 
#define _MORE_SKILLS 99

typedef struct I_WANT_MORE_SKILLS
/* this struct implements additional entity skills */
{
	var skill[100]; // 100 more vars
	void *data; // arbitrary data
	// ...whatever
} I_WANT_MORE_SKILLS;

action your_entity() {
	/* creating a new struct and saving it in the entity skill */
	my.skill[_MORE_SKILLS] = (I_WANT_MORE_SKILLS*)malloc(sizeof(I_WANT_MORE_SKILLS));

	/* access the struct */
	((I_WANT_MORE_SKILLS*)my.skill[_MORE_SKILLS]).skill[0] = 876; // set value
	var get_var = ((I_WANT_MORE_SKILLS*)my.skill[_MORE_SKILLS]).skill[0]; // get value
}


Re: How to add entity properties [Re: Fenriswolf] #210708
06/12/08 12:14
06/12/08 12:14
Joined: Jan 2002
Posts: 300
Usa
Rich Offline
Senior Member
Rich  Offline
Senior Member

Joined: Jan 2002
Posts: 300
Usa
Thanks very much Fenriswolf!


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

Gamestudio download | chip programmers | 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