Sign In Register

How can we help you today?

Start a new topic

Allow for optional arguments with a null default value in custom events

As per this discussion:

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.

11 people like this idea


and/or have a checkbox saying 'optional'


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.


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.

Login to post a comment