Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 1,258 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
argument in function #383621
09/22/11 18:26
09/22/11 18:26
Joined: Sep 2009
Posts: 155
France
ayks Offline OP
Member
ayks  Offline OP
Member

Joined: Sep 2009
Posts: 155
France
hi,

here is my code :

Quote:
function mfj(a)
{
   if (a==0)
   {
      ja1+=a;ja2+=a;ja3+=a;ja4+=a;ja5+=a;ja6+=a;ja7+=a;ja8+=a;ja9+=a;ja10+=a;
   }
}

it would be nice if i could write it easier..
i know use simple argument, but its a little more complicated here.

for automate the jaX+=a list, i could do smt like

Quote:
i=0;
while (i<=10)
{
   ja(i)+=a;i++;

but it can't work this way.. right ?
does anyone have a solution for do this thing ? (like the second quote but working)

thanks

Re: argument in function [Re: ayks] #383622
09/22/11 18:50
09/22/11 18:50
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Reconsider if you really don't want to use an array in this case.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: argument in function [Re: WretchedSid] #383623
09/22/11 19:04
09/22/11 19:04
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
you can do it like this

Code:
var ja[10];
...
i=0;
while (i<10) // another thing: This has to be i<10 not i<=10
{
   ja[i] +=a;
   i++;
}



you could also do it with for(){} ...but this should work, too

but in your first code:
if(a == 0) [...] ja1 += a; [...] - does this really make sense?!

and be a bit careful...
the first var in this array is ja[0] - not ja[1]


POTATO-MAN saves the day! - Random
Re: argument in function [Re: Kartoffel] #383638
09/22/11 22:14
09/22/11 22:14
Joined: Sep 2009
Posts: 155
France
ayks Offline OP
Member
ayks  Offline OP
Member

Joined: Sep 2009
Posts: 155
France
Oh, i see.. the array was the solution.
I'm so dumb.. i use array for all my "gauge" like "chronograph" but I didnt use them for this case..

First I thought it couldnt work because i needed to do the same thing with
ja1.visible=on;ja2.visible=on;ja3.visible=on;ja10.visible=on; and I think its not that simple in this case, but this is another problem.
I hope i will find a solution with that way.

edit : looks unaccessible with strings instead of variables smirk

Anyway, i'll try it right now and i guess there will be no problem.
Thanks for your 2 answers and for the detailed code and the tip.

Last edited by ayks; 09/22/11 23:00.
Re: argument in function [Re: ayks] #383758
09/25/11 02:25
09/25/11 02:25
Joined: Sep 2009
Posts: 155
France
ayks Offline OP
Member
ayks  Offline OP
Member

Joined: Sep 2009
Posts: 155
France
Excuse to ask again for help, but i need to do the same thing, instead of

Quote:
ja1+=a;ja2+=a;ja3+=a;


its

Quote:
ja1.visible=on;ja2.visible=on;ja3.visible=on;


Its more complicated since its not only variable.. and all the "ja" are panels.. I can't make an array of panels.
Can anyone tell me the method i have to look for ?

thanks

Re: argument in function [Re: ayks] #383769
09/25/11 08:33
09/25/11 08:33
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
You sure can create an array of panels like you can with every data type. What makes you think that its not possible?


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: argument in function [Re: WretchedSid] #383779
09/25/11 11:02
09/25/11 11:02
Joined: Sep 2009
Posts: 155
France
ayks Offline OP
Member
ayks  Offline OP
Member

Joined: Sep 2009
Posts: 155
France
I thought it was more complicated than "simple" variable since it has pos_x, pos_y, layer, bmap and flags.
But if you say so, I have to utilize this way.
I see a last difficulty but I'll try to advance with it for now.
Thanks for your answer

Re: argument in function [Re: ayks] #383822
09/25/11 21:31
09/25/11 21:31
Joined: Sep 2009
Posts: 155
France
ayks Offline OP
Member
ayks  Offline OP
Member

Joined: Sep 2009
Posts: 155
France
Hi again,
I advanced a bit, now i have this :

Quote:
TEXT string_array = // create an array of string with a text
{
strings = 20;
string = ("j1","j2", "j3", "j4");
layer=15;
flags = VISIBLE;
}
which is an array of string.
now i need it to work :

Quote:
string_array.string[0].visible=off;

but it don't.

2 questions :
- Is this the good way for doing an array of string ?
- If yes, can i have a tip for make the last quote work ?

thanks

Last edited by ayks; 09/25/11 21:33.
Re: argument in function [Re: ayks] #383823
09/25/11 22:28
09/25/11 22:28
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Okay:
1: You create a text with 20 strings an you initialize only the first 4. Thats bad.
2: You can make a TEXT object visible or not, but not each single string in it. To do so you need an array of TEXT and not only one TEXT object.

Re: argument in function [Re: PadMalcom] #383827
09/25/11 23:02
09/25/11 23:02
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
2: You can make a TEXT object visible or not, but not each single string in it.

That's not correct, there's a function esp. for this purpose:
txt_set(in)visible(TEXT* text,var index number of string starting at 0);


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Page 1 of 2 1 2

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