Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Reading from text files.

Author
Message
JJJ0han
17
Years of Service
User Offline
Joined: 4th Oct 2007
Location: Brisbane, Australia
Posted: 8th Oct 2007 10:39
I'd like to know if it's possible to read from text files? With this I mean, can the user modify simple variables such as

ammo=30

to different values? I want to do this because a friend of mine is a "beta tester" for my FPS game, and I want him to be able to mess around a bit since there isn't much content yet.

They read fine from the TXT file, but after I've compiled it, it just puts the file into the EXE itself. I know I can make the EXE read the media from the folder it's in, but I only want the variables.txt file to be outside the EXE, not the rest.

How would I do this? I did a few searches but one says that you need a special plug-in and another says something about data strings. Neither are helping me much.

Is there just a simple code to read the following?

Twu Kai
19
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 8th Oct 2007 12:26 Edited at: 9th Oct 2007 14:48
I think I understand what you mean, but tell me if I'm wrong (also, I'm assuming you have DBP).
You can't actually read commands directly into DBP from a txt file. I think you need a plugin for that.
Here's a bit of code that will do what you want to do. You should be able to work out what it does. Also, in this I'm assuming the line to read is a number.


Hope you understand that.


This is Bish. Copy Bish into your signature to help him take over from Bunny’s control. (Bogwizard.com - Bunny hybrids)
Clackersmith
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location:
Posted: 8th Oct 2007 15:04
Just have a look through TDK's tutorials on file access, I should be all you need to get started.

http://forum.thegamecreators.com/?m=forum_view&t=96084&b=7


And about as silly as a bum full of smartys.
And yeah, I need a signature like I need a case of the crabs.
JJJ0han
17
Years of Service
User Offline
Joined: 4th Oct 2007
Location: Brisbane, Australia
Posted: 9th Oct 2007 08:58
Hmm, I'm still having some problems. Also, yeah I've got DBP.
Here's what I got so far, but it doesn't seem to work.



It seems to open it as it doesn't use the "else" function, but it doesn't seem to use the actual things it reads.

Do I have to save the values to variables? If so, how?

Here's what I use for one of the variables:



Also, that is all that is in the text file, I removed the useless commands before and after the variables.
Twu Kai
19
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 9th Oct 2007 14:52 Edited at: 9th Oct 2007 14:54
Using the VAL command should work. I think, to make it less complicated, don't add in the things such as 'health = 100' just have a specific order, and type in '100' for the health. That way when you read the file, it's not attempting to read in the word 'health' as well. Apart from that, I think your code is fine.


This is Bish. Copy Bish into your signature to help him take over from Bunny’s control. (Bogwizard.com - Bunny hybrids)
HeavyAmp
18
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 10th Oct 2007 05:10
Heres an example.



Better to be dead, than to live your life afraid.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK

Login to post a reply

Server time is: 2024-11-25 12:47:46
Your offset time is: 2024-11-25 12:47:46