As I've read on [wiki]Config_Files[/wiki] wiki page that I can define all game settings inside conf.lua file.
If I'm not wrong, all the config i set in conf.lua doesn't affect directly the game, because config is loaded before main.lua starts, so I suppose, the config set before is visibile to the rest of the game code, or I didn't got how config should be used.
If I'm true, how can I read the config i defined in conf.lua into main.lua?
Let's suppose I've prepared in config.lua some data like fullscreen width and height taken from my machine, should I store the data inside some text/json file and then load it into main.lua?
Which is a best practice?
Best practice to manage game config options
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Best practice to manage game config options
If you are using full screen, try to use desktop fullscreen (which is a maximized window that covers everything) because normal fullscreen can break and no one likes it... really.
If you want to get info from the conf file you could do something like:
And now the t table will have all the info defined in love.conf, but this is not recommended. You can get all the information set in the config with other function.
For example to get the size of the display you can use [wiki]love.graphics.getHeight[/wiki] and [wiki]love.graphics.getWidth[/wiki] (You'll need this functions a lot if you use desktop fullscreen).
Also you could use [wiki]love.window.getMode[/wiki], [wiki]love.window.getTitle[/wiki] and so (take a look at [wiki]love.window[/wiki] in general)
The modules info is trickier but rather simple too
and if you need a module you can always do
Do you need more information than this? I hope this answer was useful for you
- If your game uses normal fullscreen and it crashes then the resolution wont go back to the original resolution.
- If your game uses normal fullscreen and the width and height is not a supported width or height then it will not go fullscreen at all.
If you want to get info from the conf file you could do something like:
Code: Select all
require "conf"
local t = {modules = {},window = {}}
love.conf(t)
For example to get the size of the display you can use [wiki]love.graphics.getHeight[/wiki] and [wiki]love.graphics.getWidth[/wiki] (You'll need this functions a lot if you use desktop fullscreen).
Also you could use [wiki]love.window.getMode[/wiki], [wiki]love.window.getTitle[/wiki] and so (take a look at [wiki]love.window[/wiki] in general)
The modules info is trickier but rather simple too
Code: Select all
if love.joystick then
--The joystick module is enabled
end
Code: Select all
require "love.joystick"
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Who is online
Users browsing this forum: No registered users and 4 guests