One of the features that used to be in our old SkookumIDE that we haven't had a chance to hook back in is a disassembly view. It would show you exactly how Sk parsed some code which is especially useful with operators and trying to figure out the order that things are evaluated.
However there is a little trick you can do to get a disassembly printed to the SkookumIDE Log.
Just wrap the code that you are curious about in a closure and then evaluate it. The result will be the closure which by default prints out a disassembly version of its code.
It must be valid code so I added a clause to the
if [not @pawn_holder.null? and @pawn_holder.is_locally_controlled?]
When evaluated this prints:
And the simplified inside of the closure so you can see that the
not took the whole
// Evaluated if above true
The operators (and other expressions) in SkookumScript uses greedy expression parsing - when looking for an expression it tries to make as big an expression as possible.
Here are two ways you could rewrite it.
With more brackets around the
if [[not @pawn_holder.null?] and @pawn_holder.is_locally_controlled?]
Or use the method version of the
if [@pawn_holder.null?.not and @pawn_holder.is_locally_controlled?]
I'm sure this is annoying and I can see how it could be confusing though hopefully this helps a bit.
This is a common pattern so I will see if I can come up with a more elegant solution in the future.