Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, Nymphodora, Quad, TipmyPip, Imhotep), 852 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
array in skill, is it possible? #328749
06/15/10 00:40
06/15/10 00:40
Joined: Mar 2009
Posts: 25
kholis Offline OP
Newbie
kholis  Offline OP
Newbie

Joined: Mar 2009
Posts: 25
Code:
#define enemy_list[100], SKILL2;


i want my entity detect their enemies id. but it failed using that way.

any ideas?

thanks

Re: array in skill, is it possible? [Re: kholis] #328750
06/15/10 00:58
06/15/10 00:58
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
i guess thats not possible at all.
I mean arrays must be defined globally,m the only way to define them local is with index of 3, (which is a vector)
but if you define enemy_list[100], skill2, your are "casting" the array to fit a variable, and you would lose the array index... so it makes no sense for me.

But there could be another answer to that....

Re: array in skill, is it possible? [Re: MMike] #328754
06/15/10 03:05
06/15/10 03:05
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
I wonder if something like this would work?
not tried:

var enemy_list[100];
var* listPtr = &enemy_list;

my.skill2 = &listPtr;

if (my.skill2[0] == whatever)
{
}

Last edited by pararealist; 06/15/10 03:05.

A8.3x Commercial, AcknexWrapper and VS 2010 Express
○pararealist now.
Re: array in skill, is it possible? [Re: pararealist] #328763
06/15/10 04:48
06/15/10 04:48
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Then why don't you try it? This would be my approach:

Code:
// Static

var array[100];
my.skill2 = array; // array is already var*!
(my.skill2)[5] = 6;
printf("(my.skill2)[5] = %f", (double)((my.skill2)[5])); // Test

// Dynamic

my.skill2 = sys_malloc(100 * sizeof(var)); // Create array
(my.skill2)[5] = 6;
printf("(my.skill2)[5] = %f", (double)((my.skill2)[5])); // Test



Also, "The editors" is the wrong forum for this... I move this thread.

Re: array in skill, is it possible? [Re: HeelX] #328766
06/15/10 05:27
06/15/10 05:27
Joined: Mar 2009
Posts: 25
kholis Offline OP
Newbie
kholis  Offline OP
Newbie

Joined: Mar 2009
Posts: 25
@MMike & pararealist
thanks for reply..

@HeelX
looks you code make sense.

big thank to you laugh

..and really sorry for wrong forum. feel free to move it to the right place.

---
i've tried your code but had no luck. this is error message while compiling: "subscript require array or pointer type <(my.skill2)[0] = 6; >"


Last edited by kholis; 06/15/10 09:29.
Re: array in skill, is it possible? [Re: kholis] #328788
06/15/10 11:09
06/15/10 11:09
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Remember that my.skill2[n] is the same as *(&my.skill2 + n)...
Code:
ent.skill2 = (var*)malloc(10 * sizeof(var)); 
*(&ent.skill2 + 2)  = 5; // set index 2 to value of 5



Last edited by DJBMASTER; 06/15/10 11:12.
Re: array in skill, is it possible? [Re: DJBMASTER] #328790
06/15/10 11:23
06/15/10 11:23
Joined: Mar 2009
Posts: 25
kholis Offline OP
Newbie
kholis  Offline OP
Newbie

Joined: Mar 2009
Posts: 25
nice trick DJBMASTER.
but the index cannot change into variable

*(&ent.skill2 + 2) = 5; //works

but
n = 2;
*(&ent.skill2 + n) = 5; // not works

need help. thanks

Re: array in skill, is it possible? [Re: kholis] #328791
06/15/10 11:38
06/15/10 11:38
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
huh? Works just fine for me...
Code:
int n = 2;

ent.skill2 = (var*)malloc(10 * sizeof(var)); 
*((&ent.skill2) + n) = 5;
	
error(str_for_num(NULL,(*(&ent.skill2 + n))));



Last edited by DJBMASTER; 06/15/10 11:41.
Re: array in skill, is it possible? [Re: DJBMASTER] #328799
06/15/10 12:26
06/15/10 12:26
Joined: Mar 2009
Posts: 25
kholis Offline OP
Newbie
kholis  Offline OP
Newbie

Joined: Mar 2009
Posts: 25
ahh.. my mistake. i declare var n instead of int n grin

thanks DJBMASTER

Re: array in skill, is it possible? [Re: HeelX] #328800
06/15/10 13:08
06/15/10 13:08
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
@ Helix
Quote:
Edited by pararealist (Today at 04:05 AM)

was just going to bed.


A8.3x Commercial, AcknexWrapper and VS 2010 Express
&#9675;pararealist now.
Page 1 of 3 1 2 3

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