Sunday, August 19, 2018

Sexy Language


Hello there everyone, I hope you like the somewhat-random post image. Lots of programming language references, you can download the full size version from here.

Story Time:

I was hoping to make this post yesterday, but my day job and real life interfered. There was a huge power surge--and a series of moderate ones--while i was at work. All thanks to the wonderful Guam Power Authority, which has managed to explode (literally) two generators in the last year through lack of maintenance. We have two car-sized diesel backup generators that have exhaust and snorkels up top, and two 8,000 gallon tanks. Each can power the facility fine on it's own, but they're there for backup and continuity, so we can switch from one to the other. This all happens thanks to an automatic transfer control system, which got hit hard.

We also have a building UPS (uninterruptible power supply) that is seriously scary. Imagine a large box, about 3 meters long, 2 meters wide, and 2.5 meters tall, that contains enough energy in capacitors to insta-gib you, and a very big bomb's worth of lithium. There are arc warnings everywhere. And it wasn't working correctly either. So I was running around in the dark with emergency strobe lights and a flashlight, to play with high voltage electrical equipment. Normally not my job, but it was the middle of the night, and you do what you have to. On the bright side, my servers all stayed powered and the diagnostics showed A-OK. :D

TypeScript Fun:

The original inspiration for the post is the conversion to TypeScript. I had some difficulties the night of the release, my own fault, just because I'm still learning the new conventions/syntax. Everything was working fine, but then when I went to compile the final version, suddenly it very much wasn't working. TypeScript is basically a superset of JavaScript, containing extra functionality and things like type notation. It compiles into standard JS, which is what your browser (and the game) uses. Because I'm still in the process of converting, there's a ton of errors, mostly type related, that show up when compiling, so it's not terribly helpful to look at those messages (there was about 1,200 of them). 

The problem turned out to be that I had been compiling with TypeScript 3.x, but on my other computer that I moved to, I had 2.x... and it took me a while to realize what was going on. Also apparently got a few errors related to type with the parser, I was using overloading, but because I didn't add the syntax to do it for typescript, it was causing some issues. Live and learn ¯\_(ツ)_/¯

I spent yesterday pre-explosion working on proper conversion to TS. Despite the frustration at release time, it's been quite handy so far. In fact, it already helped me catch some errors in my code. They weren't breaking anything, thanks to being fail-safe, but they also weren't doing their job properly. That added to the ability to get more information with intellisense for function parameters and returns (and catching more issues with new code), I'm quite happy with the switch.

Data Standardization, NPCs, and performance.

In the process of going through the code to fix TS errors and add type information, I realize that I'm going to be working with the data structure of NPCs and the PC a good deal. So far the structure has grown as the game as grown, and I've been generally following the organization I set out in my original design plans. So while the actual structure of the data is organized, the code creating it is not. I've been doing a few things to slowly bring that into line, but needing to properly type things for TS is something of an opportunity to handle everything at once where it will be more efficient. Since I've been planning to do this anyways, it'd be silly not to do it now when it'd be fastest.

This isn't a huge departure my short-term plans. I'm still going to be working on the major tasks planned for the month (discussed in an earlier post), still focusing on AI primarily, I'll just be shifting some of the lower-priority items back a little bit.

Some advantages:
  • Organized structure combined with TypeScript will make using the code easier and faster.
  • Planned NPC data migration expands capability to use NPCs, making some other areas (like in-world NPCs) easier to implement.
  • Refactor of some primary data objects should improve performance fairly dramatically, particularly passage navigation.
  • Combined with the expansion of chain-able functions, a whole range of coding tasks should become easier/faster, and more reliable.
  • Working on all this is a good chance to start specifying information for the API, at least the very basics. (and the API will be simpler thanks to the above items).
  • The process of implementing mod interfaces and planned backward compatibility code will be easier.
  • Increased capacity for NPCs.
Some disadvantages:
  • Further departure from Twine/SugarCube standards. This means a little more work when updating versions of the story format.
  • As mostly pure framework development, it's not very visible to the casual player.
  • While performance during play will improve, performance during saving and loading will decrease somewhat because of JSON conversion overhead.

Website Stuff:

I've added some tools and resources to the website, so that the collection of items previously contained in posts or specific releases can all be accessed from one place. This includes the most up-to-date AI tools and mod image/game image tool, among others. I've also added more writing resources, as well as the demonstration mod files. Eventually I want to make a tool to make specifying NPCs easier. With hundreds of variables each, and a complex interface for the procedural generators, a tool will be super handy. It'll also simplify building custom NPCs in the game when that functionality is added.

Anyways, that's enough for now, and it seems like there's some sort of internet outage now (using my phone to finish this). I'll leave you with a WIP picture of our lovely Morkovka:



2 comments:

The Seedbed Release - v1.31

Update: So all sorts of shit happened, mostly a killer migraine and then discovering this morning that someone using git as...