BP Graph Skookum'ized


#1

This is what a top-down move and rotate scheme looks like when it’s converted to :sk:. Notice any differences?! :wink:

(Click to enlarge)

 

Stay Skookum!


#2

I just noticed that in all the examples there is no indentation after the square brackets and the brackets themselves get indented from the line above. I have always indented after brackets in every language and have them line up with the line above.

Is there a reason behind that or is it just your style? Do you guys have a style guide that you try to adhere to?


#3

Correct, that is just an indentation style.
The one you mentioned is called Allman and the one showcased here is called Whitesmith which is our standard at Agog Labs.

There are many styles out there and programmers from different backgrounds and generations prefer different ones. But as long as you’re consistent within your own code library and across your team, it shouldn’t really matter what you use…


#4

I love this!

What is the #? This is new to me yaw#GameLib...?


#5

It is a named argument.

We thought that might be interesting.

A named argument allows you to specify a particular argument by name and enables skipping over any earlier arguments - this is really handy for some routines that have many default arguments. You can also skip over arguments by omitting them and just using a comma , though named arguments can look a little cleaner and are more informative.

Named arguments may only be used at end of the argument list – and once used may only be followed by other named arguments. Named arguments may also specify an argument for a group parameter, but must be compatible List object. Named arguments are evaluated in parameter index order regardless of order they appear since defaults may reference earlier parameters.

There are lots of little gems in the language that we have yet to fully document though they are buried in the syntax if you have the time to dig them out. More docs will come eventually.


#6

Don’t get it. Can you explain what it actually does in his example?


#7

Gladly! :slight_smile:

The method in question up there is make_rotator.
If you take a look at its declaration, you’ll see the following:

(Real roll  : 0.0,
 Real pitch : 0.0,
 Real yaw   : 0.0
) RotationAngles

So we have 3 parameters that are set to some defaults. For my purposes, I only want to rotate around the z-axis or yaw. I could have made my call as so:

add_actor_world_rotation(MathLib.make_rotator(,, GameLib.world_delta_seconds * axis_value * @rotate_speed))

which is still correct. But instead of just skipping over default parameters with a , I can explicitly pass in my parameter by including the name; in this case, yaw. And so I wouldn’t have to use commas to skip over to the parameter that I care for:

add_actor_world_rotation(MathLib.make_rotator(yaw#GameLib.world_delta_seconds * axis_value * @rotate_speed))

Here’s a more generic example. Assume a method foo:

SomeClass@foo()

(Class arg1 : bla,
 Class arg2 : blu,
 Class arg3 : bli,
 Class arg4 : ble
)

Now say I only care about passing in arg4 as I’m quite happy with the defaults of the 1st three. Traditionally, you’d have to do foo(,,, bling). Sometimes this can get confusing as you’re counting out the commas and have to keep switching back and forth between your code and foo's declaration. With :sk:, you can just go foo(arg4#bling) and boom, you’re done! foo is called with the 1st three default arguments and my explicitly specified bling.


#8

Thanks, that did it. Nice feature indeed. Unless the parameter name changes along the way and everything explodes. Would be nice to have refactoring functionality along those lines. :innocent:


#9

Well yeah, if yaw were suddenly renamed to yo, the culprit programmer would be bombarded by tons of compilation errors! :laughing: But then they’d have to make all the fixes themselves. A regular expression in a Find All Replace All could take care of it! :wink:


#10

A big part of our future tech will be a more sophisticated SkookumIDE including fancy refactoring. :madsci: