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.

DarkBASIC Discussion / Creating a parameter file

Author
Message
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Apr 2003 21:52
Ok...I would like to create a parameter file so that I can change my settings in the file (rather than the code) and load them into variables.

I have seen all the READ FILE/BYTE/WORD/LONG/FLOAT/STRING commands, but would like advice on which to use.

What I would like in my file is something like this...

[CAR 1]
MaxSpeed=100
Texture="car1.bmp"

[CAR 2]
MaxSpeed = 120
Texture="Car2.bmp"

Any ideas? Hopefully, I will be able to create an include file with a function to return specified elements. I'll post any code I/you/we come up with.
Thanks in advance.
All the Best,
StevieVee
andrew11
22
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 18th Apr 2003 22:02 Edited at: 18th Apr 2003 22:03
You could use something like this:

Set up a file like this:



Then use:



Read string reads one line of data to a string. To convert the string to an integer use VAL() command.

The only problem with this is that the player can edit the files.

All programmers are playwrights and all computers are lousy actors." -Anon.
<--- Uh... Um... Oh I forgot
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 18th Apr 2003 22:49
Yes, unless you create some basic encryption algorithm within DB so that the player won't know what he's editing or how to do it. I believe DBP has support for this natively. I'm sure you don't need something complex, maybe just a simple reversable equation or two to apply to your values.
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Apr 2003 23:55
Thanks guys, based on this I think I'll write lines in pairs - parameter name, then value.

I have looked at a saved array - these are encrypted in some way. For my use, I don't need it, I actually want the user to be able to modify the file.

Thanks in advance.
All the Best,
StevieVee
andrew11
22
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 19th Apr 2003 00:03
If you want make it less readable, use read byte, word, or long.
If you know what your reading then you don't need parameter name.
Save array dosen't use encryption, it just saves it in a format understandable by DB, but not humans.

All programmers are playwrights and all computers are lousy actors." -Anon.
<--- Uh... Um... Oh I forgot
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 19th Apr 2003 00:09
Yeah, simply in binary. This is unreadable by most, save the folks at /. and ThinkGeek. *recalls the YOU ARE DUMB binary shirt*

Login to post a reply

Server time is: 2025-05-16 20:55:41
Your offset time is: 2025-05-16 20:55:41