Running other files like servers in threads
Posted: Tue Jan 02, 2018 4:09 pm
So I guess I'm a bit lost here my friend and I started working on game and our progress has been halted due to the lack of understanding of how threads work aperently. So if someone could please take the time and explain what I did wrong that would be rad.
Goal: We would like to have the server run when you hit the host server button and that would also double as single player where you could disable/enable player joining like minecraft kinda.
Problem: The problem that we are having is that the thread that the server should run on won't stay running and just stops.
Curent Progress: This is how I thought threads worked but this does not work how I thought it would, it runs the server file once and if you put the thread:start in love.update well then it just keeps restarting the server like expcted.
I also tried making a main.lua that started 2 threads but that did not work.
This is also not a problem with the app as the server part does work fine if you start it as its own app. This is just me not understanding the thread part and yes I did look at older posts to try and find something helpful before posting but I didn't see any thing that was able to help with this problem.
Our project's github is
https://github.com/NetDelve/laughing-engine/
so you can look more at what we have if needed or if you just want to check it out.
Goal: We would like to have the server run when you hit the host server button and that would also double as single player where you could disable/enable player joining like minecraft kinda.
Problem: The problem that we are having is that the thread that the server should run on won't stay running and just stops.
Curent Progress: This is how I thought threads worked but this does not work how I thought it would, it runs the server file once and if you put the thread:start in love.update well then it just keeps restarting the server like expcted.
Code: Select all
--main.lua
thread2 = love.thread.newThread("server.lua")
thread2:start()
Code: Select all
--main.lua
thread1 = love.thread.newThread("client.lua")
thread2 = love.thread.newThread("server.lua")
thread2:start()
thread1:start()
Our project's github is
https://github.com/NetDelve/laughing-engine/
so you can look more at what we have if needed or if you just want to check it out.