Feature request: project parameters and detect device/user agent
-
Thanks for the suggestions.
One way to implement the URL parameters is like this: if the URL contains “gameid=35”, and the project already contains a variable named “gameid”, then we will set its value to 35 upon loading. This will work for your use case, right?
For device properties, we can add these predefined variables.
@info-creaticode Yes, that’s perfect! So the URL parameter feature suggestion is already a feature?
-
@info-creaticode Yes, that’s perfect! So the URL parameter feature suggestion is already a feature?
No, we can add it like that. It will take a while on the queue.
-
No, we can add it like that. It will take a while on the queue.
@info-creaticode Oh ok. I’m excited for when these get added!
-
@info-creaticode Oh ok. I’m excited for when these get added!
@jeffreyrb03-gmail
same!! -
Thanks for the suggestions.
One way to implement the URL parameters is like this: if the URL contains “gameid=35”, and the project already contains a variable named “gameid”, then we will set its value to 35 upon loading. This will work for your use case, right?
For device properties, we can add these predefined variables.
I just thought of a way better, easier, and more succinct way to implement this that would take like a day at most.
So you just need to make a new sensing block called [read URL parameter (input)]. I made a mockup of it below with scratchblocks:

What this does is just read the current URL, and only uses what’s after the ? symbol. Then, it looks for the parameter (in this case, gameid), and returns it’s value.This is very easy to do in JavaScript. I don’t know how you guys add blocks to CreatiCode, it probably may be different to writing Turbowarp extensions (which I haven’t done since like 2023), but here is some sort of example JavaScript code, which I am certain the inside of the function will at least be useful:
function readURLParameter(urlparameter) { const urlParams = new URLSearchParams(window.location.search); const myParam = urlParams.get(urlparameter.toString()); return myParam; }For this Javascript example, just note that I have no idea how your systems work on the inside, but I am just guessing. So, basically the function is just the block with the input. This takes the search parameters (? and everything after that) and then returns an individual one.
Then, used like this:readURLParameter("gameid");from this:

And then it’d return whatever is put there, like you said in your example, ?gameid=35
We don’t need to make a variable that will be set to a URL parameter upon loading or whatever, we could just read them anytime and it is easier to understand and use.
Also you may wonder why this is even important at all, but think about it.
Google uses URL parameters:
https://google.com/search?q=CreatiCode
Many other websites do too, like even Creaticode.
And this is also useful for me because I am doing a lot of stuff to connect a CreatiCode project and my website, and this makes that stuff almost 1000x easier. -
I just thought of a way better, easier, and more succinct way to implement this that would take like a day at most.
So you just need to make a new sensing block called [read URL parameter (input)]. I made a mockup of it below with scratchblocks:

What this does is just read the current URL, and only uses what’s after the ? symbol. Then, it looks for the parameter (in this case, gameid), and returns it’s value.This is very easy to do in JavaScript. I don’t know how you guys add blocks to CreatiCode, it probably may be different to writing Turbowarp extensions (which I haven’t done since like 2023), but here is some sort of example JavaScript code, which I am certain the inside of the function will at least be useful:
function readURLParameter(urlparameter) { const urlParams = new URLSearchParams(window.location.search); const myParam = urlParams.get(urlparameter.toString()); return myParam; }For this Javascript example, just note that I have no idea how your systems work on the inside, but I am just guessing. So, basically the function is just the block with the input. This takes the search parameters (? and everything after that) and then returns an individual one.
Then, used like this:readURLParameter("gameid");from this:

And then it’d return whatever is put there, like you said in your example, ?gameid=35
We don’t need to make a variable that will be set to a URL parameter upon loading or whatever, we could just read them anytime and it is easier to understand and use.
Also you may wonder why this is even important at all, but think about it.
Google uses URL parameters:
https://google.com/search?q=CreatiCode
Many other websites do too, like even Creaticode.
And this is also useful for me because I am doing a lot of stuff to connect a CreatiCode project and my website, and this makes that stuff almost 1000x easier.@jeffreyrb03-gmail
That could work! -
I just thought of a way better, easier, and more succinct way to implement this that would take like a day at most.
So you just need to make a new sensing block called [read URL parameter (input)]. I made a mockup of it below with scratchblocks:

What this does is just read the current URL, and only uses what’s after the ? symbol. Then, it looks for the parameter (in this case, gameid), and returns it’s value.This is very easy to do in JavaScript. I don’t know how you guys add blocks to CreatiCode, it probably may be different to writing Turbowarp extensions (which I haven’t done since like 2023), but here is some sort of example JavaScript code, which I am certain the inside of the function will at least be useful:
function readURLParameter(urlparameter) { const urlParams = new URLSearchParams(window.location.search); const myParam = urlParams.get(urlparameter.toString()); return myParam; }For this Javascript example, just note that I have no idea how your systems work on the inside, but I am just guessing. So, basically the function is just the block with the input. This takes the search parameters (? and everything after that) and then returns an individual one.
Then, used like this:readURLParameter("gameid");from this:

And then it’d return whatever is put there, like you said in your example, ?gameid=35
We don’t need to make a variable that will be set to a URL parameter upon loading or whatever, we could just read them anytime and it is easier to understand and use.
Also you may wonder why this is even important at all, but think about it.
Google uses URL parameters:
https://google.com/search?q=CreatiCode
Many other websites do too, like even Creaticode.
And this is also useful for me because I am doing a lot of stuff to connect a CreatiCode project and my website, and this makes that stuff almost 1000x easier.Since you did all the work to spec this out, we have made a patch to add it. You can reload the playground and try it now. The new block is at the bottom of the Sensing category.
Besides reading any parameter in the URL, you can also use 3 special keywords of “user agent”, “device” and “platform”.

-
Since you did all the work to spec this out, we have made a patch to add it. You can reload the playground and try it now. The new block is at the bottom of the Sensing category.
Besides reading any parameter in the URL, you can also use 3 special keywords of “user agent”, “device” and “platform”.

@info-creaticode OH MY GOD THANK YOU!!! IM SO HAPPY!!! I’m going to use this, I am really happy that it was added in just today. Those keywords are also pretty useful, but it could interfere with an actual parameter named device or platform, so let’s just hope nobody coincidentally uses those lol. Thank you so much, I’m really happy that I can use this now.
-
@info-creaticode OH MY GOD THANK YOU!!! IM SO HAPPY!!! I’m going to use this, I am really happy that it was added in just today. Those keywords are also pretty useful, but it could interfere with an actual parameter named device or platform, so let’s just hope nobody coincidentally uses those lol. Thank you so much, I’m really happy that I can use this now.
@jeffreyrb03-gmail Also, I just tried read URL parameters (device) and it gave me “other” even though I’m using a ChromeOS laptop right now (should be “PC”)
-
@jeffreyrb03-gmail Also, I just tried read URL parameters (device) and it gave me “other” even though I’m using a ChromeOS laptop right now (should be “PC”)
@jeffreyrb03-gmail I’m so happy



these work as expected -
@info-creaticode OH MY GOD THANK YOU!!! IM SO HAPPY!!! I’m going to use this, I am really happy that it was added in just today. Those keywords are also pretty useful, but it could interfere with an actual parameter named device or platform, so let’s just hope nobody coincidentally uses those lol. Thank you so much, I’m really happy that I can use this now.
If the URL contains any of the 3 keywords like “device”, it will take priority over the actual device info.
We’ll check why it mapped ChromeOS to other.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login