2 registered members (OptimusPrime, AndrewAMD),
14,595
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
string array and panels
#61525
01/03/06 20:43
01/03/06 20:43
|
Joined: Apr 2005
Posts: 196 In a far, far away galaxy
EPATATA
OP
Member
|
OP
Member
Joined: Apr 2005
Posts: 196
In a far, far away galaxy
|
hi all!!!
My idea is to write object's names,player dialogs,npc's dialogs,etc.. in an external TXT file, and when level is loaded each line of file is stored in string arrays. This way I can easily change object's name from one to another by simply change object's index value.
Storing file lines to arrays have various advantages like: -without reading the file every time to catch the strings; -easily change string value to another by simple change model's skill value; -you can translate your game texts to any other language just editing the TXT files.
(back to problem) An understandeable example: string obj_name[0]=""; string obj_name[1]="A Door"; string obj_name[2]="An Open Door"; string obj_name[3]="An Closed Door"; string obj_name[4]="A Rusty Door";
every frame, player scans for nearby models. if found, an string is write in the screen through a TEXT panel... but with which value? The model found must have an INDEX (SKILL1 for instance), in this example, it's initially setted to 1... Now I know which value TEXT should display in the screen ( obj_name[model.SKILL1] ) ok... but now, let's suppose that player opens the door, so it's time to change the string from "A Door" to "An Open Door". To do this simple I change model.SKILL1 to 2. The process repeats as I need....
This is my basic idea, But I'm facing some troubles with the strings properties. because (at least I think) that 3DGS doesn't support STRING ARRAYS, so I cannot apply the method I said.
Any good Idea? -(ask me for more explanation if you need)
If you dont believe in God then look at the sun.
He makes blind those who only believe seeing.
|
|
|
Re: string array and panels
[Re: Grimber]
#61527
01/04/06 15:19
01/04/06 15:19
|
Joined: Apr 2005
Posts: 196 In a far, far away galaxy
EPATATA
OP
Member
|
OP
Member
Joined: Apr 2005
Posts: 196
In a far, far away galaxy
|
Yes, I know that I can use various strings in an TEXT panel but I should define each one, right?
But I want to define only one string and then save each line of the TXT file inside this string srray. This way it save my time and much lines of script.
If it's not possible then I must find another solution. Do you have any idea?
If you dont believe in God then look at the sun.
He makes blind those who only believe seeing.
|
|
|
Re: string array and panels
[Re: EPATATA]
#61528
01/04/06 16:32
01/04/06 16:32
|
Joined: May 2005
Posts: 338 Brasil
Filipe
Senior Member
|
Senior Member
Joined: May 2005
Posts: 338
Brasil
|
you can use the TEXT object just like a string array. check the manual for text.strings, it says that if the text contains more than one string, individual strings can be accessed through a [] index suffix, just like variable arrays. so, this way, you could even make an invisible text object just to hold all the strings, or you could use the same text panel to store and show the strings, using txt_setvisible() and txt_setinvisible(). obs.: i never tried this, i'm just repeating what i saw in the manual... so, if doesn't work, don't blame me 
|
|
|
Re: string array and panels
[Re: Filipe]
#61529
01/04/06 20:04
01/04/06 20:04
|
Joined: Apr 2005
Posts: 196 In a far, far away galaxy
EPATATA
OP
Member
|
OP
Member
Joined: Apr 2005
Posts: 196
In a far, far away galaxy
|
Yes, it worked! Thanks Filipe, it worked very well, more than I have expected  This way I dont need to define dozens and dozens of strings in my script  Filipe, I rate you 5 stars Thanks for your help and happy new year 
If you dont believe in God then look at the sun.
He makes blind those who only believe seeing.
|
|
|
Facing new problem
[Re: Filipe]
#61531
01/06/06 23:27
01/06/06 23:27
|
Joined: Apr 2005
Posts: 196 In a far, far away galaxy
EPATATA
OP
Member
|
OP
Member
Joined: Apr 2005
Posts: 196
In a far, far away galaxy
|
hi! It's me again (oh no!  ) Well, now I need to know how can I change the FONT parameter only of one of these strings, let's say, change FONT of string[10] to another font.
If you dont believe in God then look at the sun.
He makes blind those who only believe seeing.
|
|
|
Facing new problem part II
[Re: EPATATA]
#61532
01/08/06 20:53
01/08/06 20:53
|
Joined: Apr 2005
Posts: 196 In a far, far away galaxy
EPATATA
OP
Member
|
OP
Member
Joined: Apr 2005
Posts: 196
In a far, far away galaxy
|
it's me again!!! It's possible to do what I said in the previous post? Question #2: if you worked with STRINGS ARRAYS of a TEXT panel then you probably note that strings can be showed in unsorted order. I.E.: string3 string9 string1 string7 and so on... Which code I use to know which line of TEXT the string is occupying? Need a reply, please help 
If you dont believe in God then look at the sun.
He makes blind those who only believe seeing.
|
|
|
Re: Facing new problem part II
[Re: EPATATA]
#61533
01/08/06 21:45
01/08/06 21:45
|
Joined: Oct 2002
Posts: 4,753 Munich, Bavaria, South of Germ...
TripleX
Expert
|
Expert
Joined: Oct 2002
Posts: 4,753
Munich, Bavaria, South of Germ...
|
1) this is actually not possible because of the build up of the TEXT object. 2) String arrays are always shown in the correct sort. Maybe check txt_setvisible / invisible A small addition: The first question can be realized with the new txt_create command: Code:
var Txt_Array[20]; TEXT* txt_pointer; //... var a = 0; while(a < 20) { Txt_Array[a] = handle(txt_create(1,1)); a += 1; }
//... txt_pointer = ptr_for_handle(Txt_Arrray[0]); txt_pointer.font = font;
Triple-X
|
|
|
now the problem is the line feeds ( \n )
[Re: TripleX]
#61534
01/13/06 22:32
01/13/06 22:32
|
Joined: Apr 2005
Posts: 196 In a far, far away galaxy
EPATATA
OP
Member
|
OP
Member
Joined: Apr 2005
Posts: 196
In a far, far away galaxy
|
hi again Now, I want to line feed the strings with \n. But why it not work when I insert it inside the TXT files? It works only through script?
If you dont believe in God then look at the sun.
He makes blind those who only believe seeing.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|