Friday, July 3, 2015

A foolish code aliasing mistake Rpg Maker coders should avoid

To quote a line from Treasure Island "I own myself an ass."

Why? Because I made a very foolish rookie coder mistake when working on my current game project that has made every build since the errors were introduced have game breaking bugs, and it was because of foolish oversights on my part.

The issue was that the minigame scripts I used for my ingame casino lacked sane exit conditions for the scene window script they were intending to alias, and it caused my entire project to be retroactively corrupted.

However, I'm getting ahead of myself, let me explain aliasing in coding terms.

Aliasing in Ruby code (which RM VX Ace uses) means code that does one thing is rerouted to an alias, or alternative. For instance, if I aliased the word "apple" to be rendered "orange" in a program determining how many uses of the words apple and orange were in a block of text, all it would result in finding nothing but uses of "orange', since "apple" was aliased to render as "orange".

This is fine, but if an alias is not sanely terminated when you need the program to render "apple" as "apple", it will continue to render "orange" even when you need "apple", which will retroactively screw up everything afterwards since the aliasing never terminated sanely, so everything using the original code will be horribly screwed up.

In that sense, I own myself an ass, because I did not check to make sure the minigame scripts I imported sanely terminated the aliasing for their custom window scenes and reverted back to the stock settings, which was causing all sorts of anomalies in the display of all window scenes afterwards, and while some errors were not immediately apparent, I should have exercised due diligence to make sure the alias terminated sanely, since that would not be easily detected at first since aliasing does not ordinarily cause game crashes if it affects non vital code, such as the rendering of window boxes.

I have fixed the issues and confirmed them resolved, but this was a mistake I made due to lack of adequate back checking of the scripting calls, and I advise anyone importing any script into their game that uses aliasing of stock code make sure the alias terminates sanely, else your game will retroactively be corrupted in terms of functionality.

This tip also applies to Ruby coding in general.

No comments:

Post a Comment

A Farewell to My Father

 My father just passed April 1, 2024 6:36 PM. For those reading this, I want to make absolutely clear the world lost a great man named John ...