Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
0 registered members (), 631 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to add variables to a Entity? #179131
01/21/08 18:20
01/21/08 18:20
Joined: Jan 2008
Posts: 4
N
NoDawn Offline OP
Guest
NoDawn  Offline OP
Guest
N

Joined: Jan 2008
Posts: 4
I want to add a variable to an entity, created using ent_create. I want to be able to call this variable like this: entity.variable, like how most objects seem to work in Lite-C.

Is this possible?

Re: How to add variables to a Entity? [Re: NoDawn] #179132
01/21/08 18:28
01/21/08 18:28
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Entities have 100 skills. You can rename the skills with #define.

If that's not what you want, you can create your own struct and include an ENTITY* and a variable. Then you can use the variable like mystruct.variable, and the entity like mystruct.entity (for example, mystruct.entity.x = 100;).

Re: How to add variables to a Entity? [Re: Excessus] #179133
01/21/08 20:04
01/21/08 20:04
Joined: Jan 2008
Posts: 4
N
NoDawn Offline OP
Guest
NoDawn  Offline OP
Guest
N

Joined: Jan 2008
Posts: 4
Actually, those skills are exactly what I am looking for. Is there also a way to define their type? As I understand it now, all of them are vars. But can I also make them chars for example? Or even arrays?

Also, thanks for the reaction.

Re: How to add variables to a Entity? [Re: NoDawn] #179134
01/21/08 20:26
01/21/08 20:26
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
No you can't define their type, although you can ofcourse cast to and from var when using the skills: entity.skill3 = (var)mychar; mychar = (char)entity.skill3; This is lossy when you cast from float/double.

You can use the skills as an array, I think. entity.skill[n] or entity.skills[n] or something. They're still var arrays, though.

Re: How to add variables to a Entity? [Re: Excessus] #179135
01/22/08 08:13
01/22/08 08:13
Joined: Jan 2008
Posts: 4
N
NoDawn Offline OP
Guest
NoDawn  Offline OP
Guest
N

Joined: Jan 2008
Posts: 4
It's a shame you can't define their type, but the skills were exactly what I was looking for. Thanks for the help!

Re: How to add variables to a Entity? [Re: NoDawn] #179136
01/22/08 10:29
01/22/08 10:29
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Just make a struct like this:

Code:
typedef struct SKILLS {
int values[256];
} SKILLS;



create it and save it's pointer (casted via long) into one skill. Later, you can retrieve it by making a pointer of its type (SKILL*) and cast the content of that skill into it. Then you can access easily your self defined skills.

Re: How to add variables to a Entity? [Re: HeelX] #179137
01/22/08 15:27
01/22/08 15:27
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
HeelX, do you think you could post a short example?


xXxGuitar511
- Programmer
Re: How to add variables to a Entity? [Re: xXxGuitar511] #179138
01/23/08 03:14
01/23/08 03:14
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline
Serious User
PrenceOfDarkness  Offline
Serious User

Joined: Aug 2004
Posts: 1,305
New York
wait so i can do for example...

var counter = 1;
while(counter <= 100)
{
wait(1);
my.skill[counter] += 10;
counter++;
}

?


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.

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