Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make conf.lua more configuration-like #40

Closed
slime73 opened this issue Jul 27, 2010 · 10 comments
Closed

Make conf.lua more configuration-like #40

slime73 opened this issue Jul 27, 2010 · 10 comments
Labels
feature New feature or request

Comments

@slime73
Copy link
Member

slime73 commented Jul 27, 2010

Original report by Robin Wellner (Bitbucket: gvx, GitHub: gvx).


The current syntax for conf.lua seems a bit over the top:

function love.conf(t)
    t.title = "My awesome game"
    t.screen.width = 400
    -- etc.
end

Wouldn't it be better (considering Lua's origins as a configuration language, to make t the environment for conf.lua, so one can use:

title = "My awesome game"
screen.width = 400
-- etc.

It also makes it a bit easier to generate a write-dir version of conf.lua, so users can change the default resolution in-game, etc.

I'll write a patch for this if necessary.

@slime73
Copy link
Member Author

slime73 commented Jul 27, 2010

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


Hmm, interesting...

@slime73
Copy link
Member Author

slime73 commented Jul 27, 2010

Original comment by Robin Wellner (Bitbucket: gvx, GitHub: gvx).


So, here is a patch, to show how easy it would be:

diff -r 8c524628753e src/scripts/boot.lua
--- a/src/scripts/boot.lua	Sat Jun 26 19:10:58 2010 +0200
+++ b/src/scripts/boot.lua	Tue Jul 27 11:57:31 2010 +0200
@@ -246,13 +246,13 @@
 
 	-- If config file exists, load it and allow it to update config table.
 	if not love.conf and love.filesystem and love.filesystem.exists("conf.lua") then
-		require("conf.lua")
+		love.conf = setfenv(love.filesystem.load("conf.lua"), c)
 	end
 
 	-- Yes, conf.lua might not exist, but there are other ways of making
 	-- love.conf appear, so we should check for it anyway.
 	if love.conf then
-		local ok, err = pcall(love.conf, c)
+		local ok, err = pcall(love.conf)
 		if not ok then
 			print(err)
 			-- continue

The second change could even be left alone if you want.

Also, this doesn't check for errors in loading conf.lua, but then again, the previous version doesn't either.

@slime73
Copy link
Member Author

slime73 commented Jul 27, 2010

Original comment by Bill Meltsner (Bitbucket: bmelts, GitHub: bmelts).


I don't know how forward-thinking we want to be here, but Lua 5.2 has deprecated setfenv, and assuming that we want to upgrade at some point, it might be prudent to try and figure out an alternative. Maybe.

@slime73
Copy link
Member Author

slime73 commented Jul 28, 2010

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


It still has some form of function environments, forgot how to do it, but they're no going to remove the setfenv functionality.. I think.

@slime73
Copy link
Member Author

slime73 commented Jul 28, 2010

Original comment by Robin Wellner (Bitbucket: gvx, GitHub: gvx).


IIRC 5.2 has the local _ENV for the environment, so it'll have to set that in some way.

@slime73
Copy link
Member Author

slime73 commented Jul 28, 2010

Original comment by Robin Wellner (Bitbucket: gvx, GitHub: gvx).


Also, I think setfenv is kept in the debug library (which has to be required anyway for the error handler).

@slime73
Copy link
Member Author

slime73 commented Jul 31, 2010

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


You'd remove some (as far as I know unused) functionality, and lose backwards-compatibility, so, what is the big gain here?

@slime73
Copy link
Member Author

slime73 commented Jul 31, 2010

Original comment by Robin Wellner (Bitbucket: gvx, GitHub: gvx).


Simplicity and easy for lovers.

@slime73
Copy link
Member Author

slime73 commented Aug 4, 2010

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


On IRC we came to conclusion that we'd leave it how it is. (or at least, I came to that conclusion :P)

@slime73 slime73 closed this as completed Aug 4, 2010
@slime73
Copy link
Member Author

slime73 commented Sep 6, 2010

Original comment by Luiji Maryo (Bitbucket: luiji, GitHub: luiji).


Could you please post more information onto why you came to this conclusion, Bartbes?

@slime73 slime73 added major feature New feature or request labels Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant