various Boo questions

Boo looks pretty interesting. I’ve dabbled in Python now and again, so even more interesting. An Emacs mode doesn’t appear to exist for it, so I’ve got the Unitron stuff turned on as shown in the Wiki. Seems to work fine as far as Unitron goes.

Mixing scripts: I read in a couple of forum posts that it’s not advisable to mix script types in Unity. Is this true? In Standard Assets there is already a mixture of C# and Javascript. Does the problem arise when you mix Boo and Javscript in the same Level, or Project or? I guess it shouldn’t be hard to rewrite the example scripts Javascript to Boo.

Boo examples: where are some examples of using Boo in Unity? It would help to read some Unity code in Boo. I am interested in some of the idioms or cool things people are doing. Like spawning bosses with boo generators, or some madness like that. :shock: Nonetheless, I sure I’ll be mostly translating Javascript examples to Boo.

Boo version: what version of Boo is in Unity 2.1?

Boo differences: what are differences if any, from the Boo that is documented on http://boo.codehaus.org/

monodevelop: Is anyone writing Unity Boo scripts with monodevelop on Mac OS X? I tried to get it all installed and running tonight but gave up after an hour so probably going with Unitron instead.

Thanks

Boo is a mix of Python and a C-style language. It’s inspired by Python but much of the specialties of Python are lost. You are getting better support for object-oriented programming and a syntax I really like (no semicolons and no curly braces!) though.

You can do everything that can be done in JavaScript and you can do almost everything that can be done in C#. You get a nice and much less verbose syntax in return, though.

Mixing scripts is not bad. It’s one of Unity’s advantages and if it helps you, you should use it. There’s a limitation though: Scripts in the same compilation level and from different languages can’t access each other. That’s not a problem in most cases and I think you can solve most with a bit of work.

You can look in the wiki for some scripts written in boo:
http://unifycommunity.com/wiki/index.php?title=Category:Boo
(I don’t think all scripts are tagged so you might also want to just look through all the scripts).

There’s also the boo group that helped me in some more exotic cases when there’s too little information in the official documentation:
http://groups.google.com/group/boolang

To determine the version of Boo Unity is using you can print the global var BooVersion, like
Debug.Log(BooVersion)

I’m using TextMate and adapted the Python bundle for Boo. If you’re interested I can clean it up a bit and put it up here.

Adrian, thanks for the info. Sounds good. If you could share your Boo bundle for TextMate that would be awesome too.

I would like that, too, Adrian.

I also decided to use Boo for low-level and Javascript for high-level in my project. I also tweaked a Python bundle for TM for Boo but I’m sure anyone else’s would be better

I’m giving my brain a break and playing all the new games right now though for a bit before I go back to coding again. /willpower! :slight_smile:

I started with JavaScript (because its what I was familiar with), moved to C# (because I wanted the type-safety), then moved to Boo (because its a type-safe language like C#, is far less verbose than C#, and writes quickly like a scripting language).

It seems mono, and thus Unity, will use whatever version is installed. I installed the most recent version of Boo (0.8.2) and that is the version Unity uses (I forget what version Unity ships with).

The language as described within the various documents on the Boo home page is fully useable in Unity (assuming version 0.8.2)

For an editor, I go the VMWare->WinXP->SharpDevelop route. SharpDevelop has great, out-of-the-box support for Boo, including a build-in Boo console that allows you to test out code snippets from within the editor.

As far as idioms, I think a rather cool one is instead of writing stuff like this:

while Input.GetKey( "escape" ):
     yield WaitForSeconds( 0.10 ) 

if rbody:
     Destroy(rbody)

you can write:

yield WaitForSeconds( 0.10 ) while Input.GetKey( "escape" )
Destroy(rbody) if rbody

Another neat feature is how dead-simple it is to write custom events:

1) Define your event within a class:
      event eventMyEvent as callable()

2) Register/un-register for event notification:
      MyClass.eventMyEvent += AHandler // register
      MyClass.eventMyEvent -= AnotherHandler // un-register

3) When ready the class signals the event and all handlers get called:
      eventMyEvent()

If you get stumped as to how to script Unity using Boo, search the forums, and if that fails, post a question: I sure someone will be able to help! :slight_smile:

David, thanks that event handling trick is very cool!

@Adrian, if you can share your TextMate bundle that would be awesome. Don’t bother cleaning it up… I am using the Python bundle for Boo scripts, and it works surprisingly well. The syntax hiliting and code folding is a bit off.

@David, does SharpDevelop do intellisense/completion for UnityEngine, or just for Boo core language stuff? Thanks again

Just add the Unity Engine Assembly (UnityEngine.dll) as a “Reference” when you create a new SharpDevelop project, and you’ll get full intellisense, auto-complete, type checking, etc., etc., for the entire Unity API.

The UnityEngine.DLL is found within the Unity.app bundle, under Contents/Frameworks.

I just copy the DLL to a convenient location on my WinXP virtual machine and refer SharpDevelop to that copy.

Ah thanks. I got it now. This really helps to learn the APIs on Unity, and Boo!