Modify tiles walkability in OpenSpace (on-the-fly)

This post applies to OpenSpace 1.x, but may apply also to 2.x (I didn’t study it yet!).

One major issue for OS1 owners is controlling avatar’s movements all the time long. Full control over the avatar. All the methods and properties related to avatar movement and re-creation of the tile-map according to new settings are private, closed. You can’t access and modify them unless you purchase a source license.

But here we go with a custom solution, which may be helpful for you in some situations as it was for us. As there is no available method to prevent avatar movement (ie, the user clicks in a tile and the avatar walks there in despite of what you say), the only solution is preventing user clicks!

Simple, not smart, but working solution.

And how in hell you do that? Also simple: place a transparent-clickable movie-clip in the tile, so it catches user clicks and nulls them. Just iterate over OpenSpace.getChildAt(0)’s children (the tiles) and do the job.

And now a few hints, as the situations are very different depending on your needs…

You can’t moveMyAvatar() or teleportMyAvatar() to the current tile –> this way you can’t prevent avatar movements! So, before user clicks, you must evaluate and decide if the avatar can walk (click, if you use the suggested workaround).

If you can’t decide prior to user’s election if he can walk/click, then you must evaluate after he clicks and starts walking. In that situation, take into consideration the previous paragraph. As you can’t moveMyAvatar() or teleportMyAvatar() to the current avatar’s coordinates (as coming from getCurrentTile()), move or teleport the avatar to a different tile.

There is a variety of events you can use to evaluate your conditions (ENTER_TILE, TILE_SELECTED, etc.), so most probably you will find some solution to your headache 😉

EDIT: Appart from the exposed method, still valid, would be nice to take a look to the following approach: dispatch a first moveMyAvatar() to a fake tile, so OpenSpace registers as current-tile the next one in the pathfinding, the issue a new moveMyAvatar() to the current (real) one.


AppleScript, mother tongue of Mac’rs

Before you were a Codewarrior addict, later Carbon libraries consumer, then Cocoa, then Obj-c, then iPhone developer, then what!

If you are a Mac user (not developer, being old or new to the business), AppleScript is your friend. In fact, any OSA-based language or “dialect” if I can call it so (such as appscript by Has or some handmade experiments by Phillip Aker). Apple Events. Application Intercommunication. Sounds like simple, but it’s the marmalade (not to talk about glue) of the daily workflow of hundreds of thousands of Mac users.

Come to mind other “experiments”, like “basic” (being Real or MS) or JavaScript for apps (such as Adobe’s apps or Air), but that is just System/App communication. It’s fine, but not in any way a checkpoint.

Although Qilania lives in a Ubuntu-driven server, many automation tasks are done in various “slave” machines, and many of them are driven by AppleScript, specially mirroring and db integration. For example, you can make tiny changes to a SWF file, and see them live in a few seconds. First, on the local server. Then, in the live server. And also changes are propagated to backup disks and so on. Magic under a double-click. Lots of technology involved: network connections, remote servers via ssh or sftp or scp, various desktop applications, etc. And one scripting language to rule them all: AppleScript.

I can ensure today, Sep 10th 2010, there is not programming language to acomplish most of these tasks we solve in a few seconds in Qilania, not in Mac nor in Win or *nix.

AppleScript, the marmalade and mother tongue of all Mac users.

ActionScript 3 madness

Many people in the big corporations thinks now it’s time to move to AS 3 their oldies (I heard of people still using AS 1 code). But seems they are only interested in quick transcodings (concept which isn’t possible, at all, unless we are talking about 10 lines of code).

In Pescados Software we use AS only as a tool, so we moved to AS 3 when we needed it, but allways for new projects. Re-usable AS 2 code was finally thrown, as most of times we found it wasn’t so “re-usable” at all. I think AS 3 is a good starting point to make new “solid” stuff. Although I’m not specially satisfied with the performance and “features” of the newer versions of Flash Player, I think AS 3 is a pretty decent language which many people coming from other programming languages (such as Java or PHP) adopted easilly, and others like us (more in the “design side of Flash”) can adapt-to, coming from the background usages of AS 1 and 2.

Still, from the end-user point of view, I don’t see many advances (watching silly HD videos in Youtube is no more than watching silly videos at all, only to mention one of the best new features of the latest FP versions, quite unrelated to AS 3 at all). If we spend the new power of AS 3 creating special effects (which aren’t so special at all), I will feel like a monkey with a gun. We must evolve and create the web 2.0, before the web 3.0 arrives so soon.

AAA (Adobe Attacks Again) and bugs

CS5, which we could as well call C$5 or C$$. I will take a look to the trials, but I don’t think I will find something interesting for me. I didn’t with CS4.

I’m so much concerned with the performance of the free Flash Player plugin that I’m not interested at all with any new products concerning IDEs, while they support ActionScript 3 (which means CS3).

Now, after years working fine, seems I can’t input my own language’s characters in a Flash text field. I can’t type “cáspita” in Safari or Chrome. Which is a dramatic issue. Now our users can’t play anymore the “Game of Wishes”, where everyone can (could) type their wishes. Not, unless they use plain ASCII in their native language or we rotate 180º and use a different programming language (!).

Also, seems there is some issue with layers (DIV) and Flash, as many sites stopped working fine in both Safari and Chrome (not to mention other browsers with less impact), including King of Kungfu (Facebook) and even Adobe’s own site.

While this isn’t solved (I hope it will), we won’t consider taking a look to CS5, not to talk about the previous CS4.

Certain issues (every app and platform has its own issues) affect so much one’s daily work that, being an old-time believer, you may consider certain alternatives which are doing their own way, such as Silverlight. It’s not that you love one or another. It’s just matters of daily tasks and production. I can’t spend months for Adobe to restore Unicode support or wmode in certain browsers (a long reported issue and still active!), as well as my customers won’t wait for me.

Flash bitmap filters (ie: DisplacementMapFilter, perlinNoise) and CPU usage

I was looking for a way to animate water in qilania (our virtual world) and I found some quick code using the DisplacementMapFilter and perlinNoise, which seems very realistic for our traditional way to animate stuff (more like cartoons), but is a quick and acceptable hack which can actually fit with our design and will save some time to the illustrator in chief.

But seems that kind of scripted animation (should say more “effect” than animation) consumes so much CPU, specially in the SmartFox/OpenSpace environment which uses to be 30fps by default.

After some researching and looking for alternative methods, we decided the fractal noise was looking so nice after all, but we needed some way to save some CPU and RAM for the end user, specially looking towards old machines and architectures. And we found a way to decrease it. This is a very simple tip: decreasing the frame rate. We did it this way (follows pseudo-code):

this.addEventListener(Event.ENTER_FRAME, go);
var nvar:int = 0;
function go(evt:Event):void {
		// perlinNoise stuff...

This way we reduced the filter to 1/3 (that is 10fps for a 30fps project), which saves more than 50% of the CPU at execution time.

It’s still so much, but minimum enough and, after all, we don’t have water in all our maps!

Hope this simple idea can help someone in a future: the simple, the better 😉