Hi everyone. I'm exporting my game for html5. i get the link to my game from my server, which gives some parameters (that i need in my game) beside the link. is it possible to get those parameters somehow? my link is: (serverpath)/game.html?sid=5edcf6-413477

(5edcf6-413477) is what i need

If you can get the entire URL/Link, then something like this should get the sid value from the URL (untested):

func get_sid(url_string):
	var sid_index = url_string.findn("sid=")
	if (sid_index == -1):
		print ("Error: SID not found!")
		return null
	else:
		# I don't remember if find gets the start, or the end.
		# I think it gets the start, so 4 characters (sid=) will need to be added
		var start_index = sid_index + 4
		var sid_string = ""
		while (start_index <= url_string.length()):
			var character_to_add = url_string[start_index]
			# If a new parameter has been started, then add the next character and move on
			if (character_to_add != "?" and character_to_add != "&"):
				sid_string += character_to_add
				start_index += 1
			# If a new parameter has started, then break the while loop
			else:
				break
		return sid_string

There might be a way to get the variable directly from Godot without having to parse the URL, but the above should, hopefully, work.

Hopefully this helps!

Thanks for the reply, but my problem is to get the URL :)

Ah, my bad!

Unfortunately my HTML5 exports are not working, so I cannot actually test the code, but for Godot 3.0 the OS class might provide the required information. Specifically, these functions seem promising:

print ("Command line args:");
print (OS.get_cmdline_args());
print ("Executable path:");
print (OS.get_executable_path());
print ("Name");
print (OS.get_name());

And it looks like Godot 2.1 has the same functions. I don't know if these will give the URL, but I couldn't find anything and these functions seem the most likely.

It is rather strange there is not a function for this though. It might be worth opening a feature request, assuming one doesn't exist, on the Godot GitHub repository to have this functionality added.

Anyway, my apologizes for misunderstanding and hopefully one of those functions returns the URL.

3 years later