.conf /.cfg?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
MHD
Prole
Posts: 18
Joined: Fri Nov 14, 2008 11:45 pm
Location: Denmark

.conf /.cfg?

Post by MHD »

Are there any specific reason why Löve doesn't use .cfg files?
I r awsum at looah ^^
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: .conf /.cfg?

Post by mike »

Yes. We didn't think about it. Do you want to be able to use .cfg as well? Is this good for anything? Rude?
Now posting IN STEREO (where available)
u9_
Citizen
Posts: 54
Joined: Thu Oct 23, 2008 7:12 am

Re: .conf /.cfg?

Post by u9_ »

I might be wrong about this but typical configuration filenames in linux end with .conf and in windows they end with .cfg? Or is it just microsoft that uses .cfg for some office (or visual studio) files?

Anyways, personally i think it doesn't really matter.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: .conf /.cfg?

Post by bartbes »

I'm thinking
thoughts wrote:why not?
I mean conf and cfg are both used, and as u9_ says I guess Linux uses conf more.
There's nothing against either, and it seems to be whatever the programmer thinks of first.
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: .conf /.cfg?

Post by mike »

bartbes wrote:I'm thinking
thoughts wrote:why not?
This is an issue that comes up now and then: where do we stand on enforcing our way vs allowing for other ways of doing things. On one hand it would probably be good for the person who has used cfg files elsewhere, but would the increase in code, file size and processing time really be worth it to appease that one guy? It's such a small thing to be concerned about (wouldn't be much work either), but in the long run it would be counter-productive to always bend LÖVE to people's every whim as the end result would be a bloated piece of software that tries to please everyone.

I am still unsure about this so I will leave it to rude to decide it's fate. I could go either way...
Now posting IN STEREO (where available)
User avatar
subrime
Citizen
Posts: 76
Joined: Thu Nov 13, 2008 6:18 pm
Location: Australia

Re: .conf /.cfg?

Post by subrime »

So a bit of lua history: it was originally designed as a configuration language.

This is lua's strong suit, and the love infrastructure already provides the ability to do this in a simple manner: it's called the load function. If you have your configuration settings in a file called 'something.conf', this should work:

Code: Select all

function load()
  dofile 'something.conf' -- load in the settings
-- etc
end
The only thing to remember is that the file that you load must conform to lua syntax, but this is an advantage since this is exactly the kind of the task lua syntax is optimized for.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: .conf /.cfg?

Post by bartbes »

I actually used the following code to create a (personal) hook program:

Code: Select all

love.filesystem.include("game.conf")
if not width then width = love.graphics.getWidth() end
if not height then height = love.graphics.getHeight() end
if not fullscreen then fullscreen = false end
if not vsync then vsync = false end
if not fsaa then fsaa = 0 end
love.graphics.setMode(width, height, fullscreen, vsync, fsaa)
love.graphics.setCaption(title)
And it works as intended, only problem is that the window "opens" twice.
It appears, and quickly disappears, only to appear again (however, this takes 1 sec, and it might have to do something with the amount of code in front of that).
User avatar
rude
Administrator
Posts: 1051
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: .conf /.cfg?

Post by rude »

Use display_auto = false in the config file if you want the create the initial window yourself.

If you use love.system.restart(), you should also check whether a window is already created, like this:

Code: Select all

if not love.graphics.isCreated() then
    love.graphics.setMode( ... )
end
About .conf vs .cfg: this is probably the first really pointless discussion here so far. :D

EDIT:

Code: Select all

-- I would not do this:
if not width then width = love.graphics.getWidth() end
if not height then height = love.graphics.getHeight() end
-- This is more like it:
if not width then width = 800 end
if not height then height = 600 end
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: .conf /.cfg?

Post by bartbes »

Looks like nothing is going to change :D

@rude:
Well it was just a personal thingy, not made for performance or whatever.
User avatar
tido
Prole
Posts: 28
Joined: Mon Feb 04, 2008 4:08 pm
Contact:

Re: .conf /.cfg?

Post by tido »

ACTUALLY...

*.conf DOES use ONE WHOLE EXTRA BYTE of RESOURCES because of the extra letter (*.cfg has only three). So technically, it will take a few more CPU cycles to parse that string. :shock:

Also, I'm pretty sure it will use some more cycles looking the file up on the drive.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 26 guests