Can I use default parameters in verge functions?

Can you do something like this in verge?

void FadeIn(int duration, int color, int image = screen)
{
    //code here
}

//calling the function
FadeIn(500, RGB(255, 255, 255));

Basically, so you can call the function with fewer arguments, and default the rest to set values, as a useful shorthand.

Short answer: No. Instead, either pick up a null value and assign in the function (which is a little pointless, as you may as well just pass screen here):

void FadeIn(int duration, int color, int image)
{
    if (image == 0-1) image = screen;
    //code here
}

//calling the function
FadeIn(500, RGB(255, 255, 255), 0-1);

Or better write a wrapper function with a different name, as verge does not support overloading:

void FadeIn(int duration, int color, int image)
{
    //code here
}

void FadeInScreen(int duration, int color)
{
    FadeIn(duration, colour, screen);
}
Original forum post
Talkback

There are no talkbacks on this documentation page yet. Post the first?

Post a new comment?

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.