Our games are being bundled and built as HTML5, but they use colyseus for multiplayer functionality. At each of our locations (there are three developers including myself) we each have a device running a homelab version of the server which will host the games. I’ve managed to get it setup so that when I “project>build HTML5” it still connects to my homelab’s server for multiplayer functionality, but it isn’t at the same address for each of the developers on their home networks. I’m looking to get the ip address input somehow for the “project>build HTML5” but not have this as a requirement for the production version.
My initial thought was have a file which contains the ip address and put it in .gitignore so each of the developers can change that file once to reflect their homelab, but not have to input the ip every time. The problem with this is that a HTML5 build won’t be able to access files on the device I believe.
I think so yes, from your answer to the other question about custom resources it seemed like that would be a potential solution. I now need to learn about custom resources to do this. Thank you for your help.
Not really sure how to go about accessing the custom resources on the HTML build. It does appear to be loading the file in and works for url “./”, but I’m unsure what to use for a url to the custom resources? Any advise on this would be greatly appreciated.
Custom resources are packaged inside the game archive and can be loaded the same way (sys.load_resource()) on all platforms.
I’m thinking something like this:
local server_url = nil
-- is this a debug build?
-- yes - load url to local dev server
-- no - use live server
if sys.get_engine_info().is_debug then
server_url = sys.load_resource("/dev/serverurl.txt")
else
server_url = "https://cool-game.com"
end
-- connect to server
My suggestion was based on the topic “HTML5 build with option” in mind, and also to show that it’s possible.
For your actual use case, I’d go with a user config file on disc.
E.g. check if you have a “~/.mygame/localsettings” or some other file that exists outside of your repo. The suggestion from @britzl will work for this.