+1.
Yes, please! We always end up to set the default value to "null" and check in the event var foo = Spark.getData().foo == "null" ? null :SparkGetData().foo; what is pretty ugly.
Same for me , I put "0" for optional strings and test it later in script, which is not optimal.
Checkbox would be the best option.
This would rock -- here's a prime example:
I have "equippedWep = "STARTER_SWORD". Let's say I want to bulk update, if (!attr1) then write. Sure, if attr1 (representing equippedWep) == "", then it skips it.
HOWEVER, this gets awkward for numbers:
isAwesome = 1
Let's say I upload bulk values. I don't want to update isAwesome, I can't include null. It would include 0. This means that isAwesome would become = 0. He would no longer be awesome because it's not nullable.
HOWEVER, I recently read that you can put a json value as null (no string quotes) and it will be null. I'm about to test it.
src: https://stackoverflow.com/questions/21120999/representing-null-in-json
Follow-up: Ah, didn't work
The workaround would probably be to set the default value to something arbitrary like "NULL" in strings. Compare for !== "NULL"
(gah, wtb edit feature lol, sorry)
For numbers, perhaps a -1 if it'll allow it
This workaround seems to work well for me as long as you remember to check for -1 and "NULL" lol, otherwise you accidentally replace all your player vals with bogus data ;)
Honestly, this is a very important feature. And it gets worse when you start working with leaderboards.
I'd also like to see this feature implemented.
Please add. Without this change you are forced to use workarounds that are hard to document and easy to confuse, increasing the complexity of on-boarding new personnel.
What's the threshold required to get this implemented?
I use JSON with default value set to empty object for optional arguments using simple types or passing all my custom arguments as object. Simple and clean workaround.
Even with a lot of votes, features asked are never developped. I think you could close this forum unfortunately...
Benjamin Grob
As per this discussion:
https://support.gamesparks.net/support/discussions/topics/1000083758/page/last#post-1000205583
Currently, the only way to make a custom event argument optional is by inputting a default value. This default value cannot be an empty string, otherwise the argument will be mandatory.
I (and 2 other developers in the linked thread) have run into situations where it would be desirable to make an argument optional, but take on a value of null (or empty string) as the default value.
Would be nice to have a "null default value" checkbox or similar functionality in the custom event dialog.
21 people like this idea