Game
Hensen Hopper

4 months ago

I wrote a modular language system! I can now add new entries with definitions in as many languages as I please and all from the inspector window in the Unity editor! This allows me to potentially have Hensen Hopper translated to other languages easily!


I literally thought this entire system out WHILE AT WORK over the last week haha! I got super excited multiple times and probably made my coworkers think I'm nuts by yelling things like "AHA!" and "I GOT IT!" and "This is gonna be GREAT!" out loud.

I work in a warehouse, noise isn't exactly a concern 🤣

Anyway, here's my infodump:

image.png

This is how the entries I can modify from the inspector window are structured internally. Pretty straight forward, LangEntry's contain an internal name and an array of LangDefinitions which represent the definition of that entry in a specified language.

image.png

As you might expect, the first member of the LangManager class (the script that is attached to an object in the scene through which I can define lang entries from the inspector window) is a serialized array of LangEntries, however, for the sake of ease of access by other scripts, I changed the hierarchy relating entry names to languages to definitions a bit from how it functions in the inspector window internally. What's happening in this snippet is probably a bit difficult to follow intuitively if you're new to programming, but what is happening here is all of the string data contained in the Entries array (the language names, entry names, and definitions) is copied into a hierarchy of dictionaries. The outermost dictionary maps language names to inner-dictionaries that map lang entry names to their definitions in that language (if they exist).

image.png

This copying of data from the LangEntry array I modify from the inspector from to internal dictionaries might seem pointless at first, however, this is actually a best of both worlds scenario. It allows me not only to easily add new definitions for an existing lang entry in other languages but get the definition of that entry in the user's current language without needing to loop through every entry and it's definitions to find it!

image.png

The only drawback to this approach is that I cannot modify the game's lang during runtime as the internal dictionaries are constructed on awake, but, at the same time, I cannot imagine a situation in which I'll HAVE to so that should be fine.



3 comments

Loading...

Next up

Officially gotten started with the spider!!!!!!!!

Been working on the artwork for the spider enemy!!! This is a preview of what it'll look like in-game. I am gonna remove all of these drop shadows as I usually apply those to the spritesheets themselves once I've drawn the animations.

The gang's all here!

Doki Doki Literature Club is celebrating Monika's birthday and the 8th anniversary of DDLC with exclusive stickers, avatar frames and backgrounds on Game Jolt! 

Head over to the shop to collect yours 👉 https://gamejolt.com/#shop

THE SPIDER IS COMING

Mae Borowski is the main character of Night in the Woods! It's an adventure game that tells the story of her return to her hometown of Possum Springs. She was confirmed as canonically pan in a social media post by the game's creator Scott Benson.

Last post for today! Been getting some work done on the art for the spider, so far I've drawn a colored concept art (I know I completely messed up the web) and got started on the actual sprite, well, at least the layer that will be the spider's web.

He has hands now!

The Knightling launches on August 28! Wishlist it now so you don't miss out: https://bit.ly/KnightlingSteam

To celebrate the game's impending release, we've added The Knightling Pack and The Knightling Community Pack back to the Shop!

HIS HANDS ARE ANIMATED NOW!