Console server

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Console server

Post by Sparx »

Hi there.
I didn't run Löve on a linux system yet. My server for my game running on XP takes quite some CPU ressources, without doing much.
Is there some way seting up a console server with löve?
Sparx
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Console server

Post by bartbes »

You can use lua + LuaSocket.
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: Console server

Post by Sparx »

can I sue LUBE with it?
Because my server uses it right now...
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Console server

Post by bartbes »

I believe so, I don't think I use any love-specific features, if for some reasons you do get errors when running LUBE on lua+LuaSocket just contact me, I'll be happy to recreate these functions in another way. (After all, I provide support ^^)
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: Console server

Post by Sparx »

it's very hard getting my luacode to run somwhow without löve....
Now i did using luabinaries but compiling is to much for me...
Isn't there a way I can tell love to be just a console programm... if not maybee in 0.6?

I'm looking fo an easy way running the lua programm i am writing on my windows machine on a linux server starting it via console.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Console server

Post by bartbes »

If you want a fast windows install of lua (including a few libs, one of those is LuaSocket) try this url: http://luaforwindows.luaforge.net/index.html#Download
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: Console server

Post by Sparx »

Ported the server to luaforwindows.

This is my main routine:

Code: Select all

load()
require "socket"
time=socket.gettime()

while(1==1) do
	update(socket.gettime()-time)
	time=socket.gettime()
end
and i replaced all love.timer.getTime() with socket.gettime()
the server is up and running and i can connect but alot goes very wrong, having problems with timing. And sometimes if i connect the luac file is still running but the server doesn't respond to the client....
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Console server

Post by bartbes »

I can't really tell what the problem is, but you might consider adding a socket.sleep at the end, is going to save you a lot of CPU time at worst, at best it also solves your other problems.
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: Console server

Post by Sparx »

That helped... awesome! CPU usage 0% while doing a lot of stuff....
Somehow my ping is either 0, 16 or 32..... so there is still some timing issue here. (using socket.sleep(0.001))
Now can you tell me how "require" LUBE.lua.. just now I replaced it by the actual lube code =)

And coudl you replace the 4 love.filesystem. in Lube by a lua native one?

And is there some tutorial how to port this to a linux server accessable via console?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Console server

Post by bartbes »

Code: Select all

require "LUBE"
Yes, as easy as that. You can either manually remove the elseif where love.filesystem.exists is used or start your file like this:

Code: Select all

require "LUBE"

love = { filesystem = { function exists() return false end } }
(untested, but not too much to be wrong :D)

And what do you mean by porting?

EDIT: FAIL I did mess up the code, anyway, this should work
EDIT2: Let me explain why you can just skip that elseif. That's because it is for a rarely used feature, to be precise, loading new protocols, however, I have yet to see anyone do that.
Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests