Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (OptimusPrime, AndrewAMD), 14,595 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
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 Offline OP
Member
EPATATA  Offline 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: EPATATA] #61526
01/04/06 00:28
01/04/06 00:28
Joined: Sep 2003
Posts: 4,959
US
G
Grimber Offline
Expert
Grimber  Offline
Expert
G

Joined: Sep 2003
Posts: 4,959
US
3DGS has a form of string array. the TEXT object is a string array

this also makes it easy for the sort of idea you want as you can easily load an entire .txt file into a text object with one instruction line.

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 Offline OP
Member
EPATATA  Offline 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 Offline
Senior Member
Filipe  Offline
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 Offline OP
Member
EPATATA  Offline 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.
Re: string array and panels [Re: EPATATA] #61530
01/04/06 20:09
01/04/06 20:09
Joined: May 2005
Posts: 338
Brasil
Filipe Offline
Senior Member
Filipe  Offline
Senior Member

Joined: May 2005
Posts: 338
Brasil
thanks for the stars...
and a happy new year to you too...

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 Offline OP
Member
EPATATA  Offline 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 Offline OP
Member
EPATATA  Offline 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 Offline
Expert
TripleX  Offline
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 Offline OP
Member
EPATATA  Offline 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.
Page 1 of 2 1 2

Gamestudio download | 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