Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Quad, M_D), 1,217 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
wie finde ich den index eines arrays von panels ? #413276
12/11/12 14:30
12/11/12 14:30
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline OP
Member
Ascalon  Offline OP
Member

Joined: Apr 2005
Posts: 274
austria
ich habe ein array von panels zb PANEL* panTest[10];

in diesem Panel gibt es einen Button und beim click auf diesen Button startet die dazugehörige Funktion, zb.:
function testfunktion(var _buttonNumber, PANEL* _panel) {...}

wie finde ich aber den Indexwert des jeweiligen Panels raus, wenn ich den button gedrückt habe ?

Last edited by Ascalon; 12/11/12 14:32.

my webside : www.ascalon.jimdo.de
Re: wie finde ich den index eines arrays von panels ? [Re: Ascalon] #413279
12/11/12 14:48
12/11/12 14:48
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
gib' jedem panel in dem array beim initialisieren eine eindeutige id, die gleichzeitig der indexwert ist.
Dafür kannst du skills verwenden:
Code:
panTest[0].skill_x = 0;
panTest[1].skill_x = 1;
// usw.


in der button funktion benutzt du dann das:
Code:
void btn_function(var _buttonNumber, PANEL* _panel)
{
   _panel.skill_x   <- indexwert des panels, dessen button geklickt wurde
}


MfG, Kartoffel wink


POTATO-MAN saves the day! - Random
Re: wie finde ich den index eines arrays von panels ? [Re: Kartoffel] #413286
12/11/12 15:55
12/11/12 15:55
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Oder du durchsuchst das array nach dem richtigen Panel.

Code:
int get_panel_index(PANEL* _panel)
{
  int i;
  for (i = 0; i < 10; i++)
    if (panTest[i] == _panel)
      return i;
  return -1;
}



Kartoffels Ansatz ist aber schneller. Meiner macht dann Sinn, wenn sich die Indizes im Laufe des Spiels ändern sollten.


Always learn from history, to be sure you make the same mistakes again...
Re: wie finde ich den index eines arrays von panels ? [Re: Kartoffel] #413288
12/11/12 15:56
12/11/12 15:56
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline OP
Member
Ascalon  Offline OP
Member

Joined: Apr 2005
Posts: 274
austria
cool ! vielen dank, funktioniert super ! wusste nicht dass es für panels auch skill-werte gibt wink


my webside : www.ascalon.jimdo.de
Re: wie finde ich den index eines arrays von panels ? [Re: Ascalon] #413290
12/11/12 16:02
12/11/12 16:02
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
kein problem wink

...die skill werte hab ich auch erst "entdeckt" als ich etwas ähnliches erreichen wollte grin


POTATO-MAN saves the day! - Random
Re: wie finde ich den index eines arrays von panels ? [Re: Kartoffel] #413302
12/11/12 19:01
12/11/12 19:01
Joined: May 2010
Posts: 117
Germany , Dortmund
B
Bone Offline
Member
Bone  Offline
Member
B

Joined: May 2010
Posts: 117
Germany , Dortmund
Das mit dem Panel Skills ist ja super.

Code:
panel.skill_x



Steht das x für eine Zahl? Und falls ja, wo ist die Grenze?

Re: wie finde ich den index eines arrays von panels ? [Re: Bone] #413303
12/11/12 19:05
12/11/12 19:05
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Nein, x steht nicht für eine Zahl.

http://www.conitec.net/beta/skill_x.htm


Always learn from history, to be sure you make the same mistakes again...
Re: wie finde ich den index eines arrays von panels ? [Re: Uhrwerk] #413317
12/12/12 02:25
12/12/12 02:25
Joined: May 2010
Posts: 117
Germany , Dortmund
B
Bone Offline
Member
Bone  Offline
Member
B

Joined: May 2010
Posts: 117
Germany , Dortmund
Danke für den Link.
Wie ich das nur übersehen konnte .... grin

Hier ein kleines Beispiel für den Fall, dass jemand mal mehr Platz braucht
Code:
function skillsForPanel(PANEL* pan, var num){
	
	pan.skill_x = sys_malloc(num * sizeof(void*));
	
}


function main(){

	PANEL* pan = pan_create("size_x = 10; size_y = 10;", 1);
	
	// 5 ist die Anzahl der "Skills"
	skillsForPanel(pan, 5);
	
	((var*)pan.skill_x)[0] = 2;
	((var*)pan.skill_x)[1] = 6;
	
	printf("%i", (int)((var*)pan.skill_x)[0]);
	
}



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