server/client with/without graphics/window

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
EliterScripts
Citizen
Posts: 85
Joined: Sat Oct 25, 2014 7:07 pm

server/client with/without graphics/window

Post by EliterScripts »

Hello,
So I am interested in running my game's servers on LOVE2D. I plan to be able to slap it on something like a Ubuntu Server. With that, I would like to make my game all run on practically the same code. So the server package would be the same package as the client package, no need to download separate stuff.

I specifically am thinking about having it to where a user could start the application in the terminal with the command argument "--server" or even add "--nogui"and it would startup the game, without loading graphics or creating a window.

The problem that I've ran into is that I don't want to create the window if the user executes the application as a server, while still allowing for graphics and the window to be created if the user doesn't run it as a server. So if I try loading the window and graphics module in the configuration and use love.window.close on even the first line of code, it still opens the window. If I try not loading the window and graphics module in the configuration, I cannot create a window or use any of the love.graphics or love.window functions, despite documentation that implies/states otherwise: https://love2d.org/wiki/love.window.setMode .

The problem that I see is that if I do either in the conf.lua file:
A:

Code: Select all

t.modules.window = nil
t.modules.graphics = nil
or B:

Code: Select all

t.modules.window = false
t.modules.graphics = false
I cannot use love.window.setMode . If I set either of the above modules to false or nil, and use the love.window.setMode function, I will get the following error:

Code: Select all

$ love ./
Error: main.lua:1: attempt to index field 'window' (a nil value)
stack traceback:
	[string "boot.lua"]:637: in function '__index'
	main.lua:1: in main chunk
	[C]: in function 'require'
	[string "boot.lua"]:475: in function <[string "boot.lua"]:311>
	[C]: in function 'xpcall'
	[string "boot.lua"]:645: in function <[string "boot.lua"]:639>
	[C]: in function 'xpcall'

Here's the first line of main.lua:

Code: Select all

love.window.setMode(300,300)
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: server/client with/without graphics/window

Post by grump »

Code: Select all

require('love.window')
require('love.graphics')
love.window.setMode(300,300)
Post Reply

Who is online

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