Closed AesynthGrey closed 1 year ago
The Steamworks documentation isn't super clear on what is required to make it work and the few times I tested it I haven't been able to get any usable information from it. But the function is super simple under-the-hood so it should work.
It is meant to be used for servers though, which is probably where I was going wrong before. And a server that Steam is aware of. I'm not 100% sure how you set that up to utilize it but I believe the server will have to be initialized with initGameServer() so that Steam knows what IP to send back.
I do not believe this will work with lobbies; just game servers.
Got it. Thanks for the quick response. So how do I exactly retrieve the host's ip address to use in Godot's ENet? I've read some other issues, but when I try to actually do those things it just doesn't work. Because first off...
Where do I put it? Like, how is the actual joiner of the lobby going to retrieve this? With... getLobbyData()? I've tried that, but I think it can only be called once. I want to say, Steam.getLobbyOwner().getPublicIP, but that doesn't really seem to work. What should I do to try and recreate this? Edit: If I try to use getPublicIP, it says: SCRIPT ERROR: Invalid call. Nonexistent function 'getPublicIP' in base 'Steam'.
Wait, what if I make the lobby id literally the IP address of the host and then make it so that Godot just connects to the lobby id?
Welcome! That I'm not sure, I haven't used Godot's networking since Godot 2.x actually.
Yeah, it seems getPublicIP is commented out currently. Not sure why but I'll look at it. Might be a compiling error or crash.
There are a few projects that are trying to mix Godot's HL networking and Steamworks; not sure how well they work currently. A few people in our Discord have been discussing it recently.
Your Steam.getLobbyOwner().getPublicIP() wouldn't work because lobbies aren't servers. That function just gets the Steam ID of the lobby's owner.
As for the lobby ID, Steam generates those itself so there is no way to change it. You could pass it through setLobbyData I guess. You can call getLobbyData as often as you want actually.
OK, getPublicIP is in the projects to-do list. Apparently Valve changed the integer to a struct so it completely borked the function for us. It should be fixed in the next update.
Thanks dude! When's the next update?
Probably when Godot 3.5 comes out, which should be soon.
Oh okay. I could try that setLobbyData for now, though. Thanks so much! You've been very helpful.
Welcome! Yeah, that might work out. It is an easy way to pass data back and forth. That and P2P messages. You can also check out JDare's repo for his mix of Godot's HL networking and Steamworks.
Do remember that getPublicIP only works with servers that are using Steamworks and have been initialized as servers. It won't work with anything else.
Aight. I'll keep that in mind as well. Thanks a lot! Been quite an honor to talk to a heck of a programmer.
Very welcome! Feel free to join us in the Discord if you get stuck on anything; a lot of smart folks with good ideas on networking. I will close this issue when the getPublicIP function is fixed.
So I did figure out how to get the local ip address of the host, which works locally on the same network, but I really need that getPublicIP thing. When is Godot 3.5 destined to come out fully? I've looked but I still don't know when it's gonna get out.
Here is the test build I made to see if the code changes worked. It is the version that will go live, minus any other changes we make before 3.5 releases: https://www.dropbox.com/s/lyyyb99m8yafun3/getPublicIP-test.zip?dl=0
I have no idea when they intend to release 3.5 actually. I just see updates on Twitter and Reddit every so often. It should be soon, I think, since it is in the release candidate phase.
Weird. It still says the command doesn't exist. I even ran your specific version in another folder (separate from the other editor I have) and it still gives me the error.
My bad, I didn't actually uncomment the function bind. I'll make a new one tomorrow afternoon.
Hey! It's been a day and I've been working on achievements. Is that fixed build done?
Sorry, been busy. Here is a test version with getPublicIP back in. Remember, this will not work unless you initialize a server through Steam.
Thanks! I'll definitely put you in the credits for this.
Let me know how it goes!
Um wait noob question, how do I initialize a server through steam...? I have a lobby initiated but not a server.
You'll want to check out the functions in the Game Server class: https://gramps.github.io/GodotSteam/functions-game-server.html Specifically initGameServer( dictionary connect_data, int app_id, string version_string )
.
That's weird. It doesn't seem like that's even a viable command.
Hmm, it does seem like it is missing. What the. I guess when we merged the server branch into the main some things didn't make it correctly. It'll need to be added back in or the server branch separated again, which is probably a better idea really.
Oh, nevermind, it was renamed serverInit(const String& ip, uint16 game_port, uint16 query_port, int server_mode, const String& version_string) and dumped into the main class.
Ah I see. Thanks!
So one thing I didn't anticipate is the function (getPublicIP()) returns a dictionary, not an int like the documentation says. If this doesn't necessarily work, I could learn how to use an external source. In that case, I'd have to learn how to, theoretically, run a command in Godot. Edit: Correction: it returns a dictionary of an int, but it's always 0. I'm sorta wondering how, specifically, to use the last part of serverInit (version_string).
Yeah, the documentation isn't updated for it as it technically hasn't been released in that state. I think the version string is just whatever version number the server is. That could be whatever you set it as.
OK, this fix is added to the new GodotSteam 3.17. I accidentally overwrote my changes for this test so hopefully I recreated them correctly!
https://gramps.github.io/GodotSteam/functions-game-server.html
So there's a getPublicIP() function, which I'm really interested in to get the IP address of the host.
So I'm trying to make a multiplayer that combines Godot's ENet and Steam's lobbying system. Is this function deprecated? When I try to use it, it doesn't come up with anything. Am I supposed to use it a certain way?