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
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 14,141 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
reading a text file within a resource? #111873
02/13/07 19:37
02/13/07 19:37
Joined: Apr 2005
Posts: 9
J
Joa Offline OP
Newbie
Joa  Offline OP
Newbie
J

Joined: Apr 2005
Posts: 9
i recently bought a6pro. one of the features i wanted the most was the resource creation (wrs).

the thing is, in my project i have a lot of plain text files which are read at runtime and the levels are built according to that. i'd like to include those text files in the encrypted resource file, so they can't be edited by the end user, but this doesn't seem to work: the files can't be found (everything else, models etc, that i also manually used bind to include in the wrs, are working fine).

i know that in the manual it's stated that the file must exist in the savedir. and file_open_game explicitly says that the files can't be inside a resource.

so... what are my options of reading a text file inside a resource?

thanks in advance

joaquin

Re: reading a text file within a resource? [Re: Joa] #111874
02/13/07 20:20
02/13/07 20:20
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Copy the textfile from the resource to your gamefolder - with c_script.
Then you can read out the data.

Edit: Look at: file_cpy (string destname, string srcname);

Last edited by fogman; 02/13/07 20:21.

no science involved
Re: reading a text file within a resource? [Re: fogman] #111875
02/13/07 21:08
02/13/07 21:08
Joined: Apr 2005
Posts: 9
J
Joa Offline OP
Newbie
Joa  Offline OP
Newbie
J

Joined: Apr 2005
Posts: 9
fogman, thanks for the suggestion. i have tried this, but i couldn't get it to work, maybe i'm doing something wrong?

i have e.g. a file called "myfile.txt". i do the resource, binding that file, and then i try:
file_cpy("myfile.txt", "myfile.pak");

is that right? or do i have to rename the file to myfile.pak before doing the resource?

thanks for your help

joaquin

Re: reading a text file within a resource? [Re: Joa] #111876
02/13/07 22:04
02/13/07 22:04
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Hum... this should work. Wait - have you added a wait(3) after file_copy? It might take some "ticks" to create the file.
I haven´t tested this method, but somewhere jcl stated that this is a workaround for this kinds of files (e.g. if you want to read data out of them, play videos, etc...)
For me it´s bedtime now, if you can´t get it to work, pm me. I´ll answer tomorrow.


no science involved
Re: reading a text file within a resource? [Re: fogman] #111877
02/13/07 23:47
02/13/07 23:47
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
I don't think a wait(3) is required - at least I would not know for which reason. However, you should check the return value of file_cpy. If it's zero, there was no such file found in your resources.

Re: reading a text file within a resource? [Re: Joa] #111878
02/14/07 10:28
02/14/07 10:28
Joined: Aug 2004
Posts: 176
Germany
Team_GamesArk Offline
Member
Team_GamesArk  Offline
Member

Joined: Aug 2004
Posts: 176
Germany
Hi,

you have to rename the file to .pak and then you can put them into the
resource! After that you can use file_cpy to extract them to the filename
you want.

Frank


Moderated by  old_bill, Tobias 

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