A confirmation dialog for URxvt’s Print Screen key

I use urxvt’s kuake plugin as a lighter replacement for Yakuake and, as a result, I’m using it with F12 as my “toggle terminal” keybind.

…unfortunately, that means that, every time my finger slips, I hit Print Screen.

As such, I wrote this little script you can use to Print Screen to file, with a confirmation dialog to avoid the need to keep deleting unwanted printouts.

confirm_print.sh (fixed commit ID)

To use it:

  1. Copy it to somewhere like ~/bin/confirm_print.sh
  2. Make sure zenity is installed
  3. Add these lines to your ~/.Xresources
    Rxvt.print-pipe: ~/bin/confirm_print.sh
    URxvt.print-pipe: ~/bin/confirm_print.sh
    
  4. Run xrdb -merge ~/.Xresources
  5. Restart any terminals you may have. (You are using screen or tmux, right?)
Posted in Geek Stuff | Leave a comment

Useful bits for GOG Linux Users

Over the last little while, I’ve written or researched a few little things to make my life as a Linux-using player of GOG.com games a bit simpler. As such, I thought I’d share them.

1. GOG.com – Updated Thread Count in Title

This Greasemonkey script adds the unread count for your favourited forum threads to the favicon so you can select “Pin Tab” and have an alternative to manually polling for new replies.

It’s not RSS, but it still takes a load off your mind.

2. find_broken_symlinks.sh

While not specifically focused on GOG.com or even gaming, this multi-mode script has proven very useful.

Modes of operation:
--all-external
  Show all symlinks targeted outside the current directory
--all-home
 Show all symlinks targeted inside /home
--all-my-home
 Show all symlinks targeted inside the current user's home directory
(anything else)
 Show all broken symlinks originating inside the current directory

I originally wrote it because:

  • Some of my Linux-native ports store their save files in the game’s application folder
  • I symlinked the save files into my homedir so nightly backups cover them
  • My games folder is on an external USB drive
  • Supposing I ever want to let a friend try the games on their computer, I’ll need a way to identify the folders I need to mkdir -p to unbreak the symlinks.

Caution: It’s a bit of a hack and will get confused by folder/filenames containing newlines. (Doing it properly and efficiently is very awkward and painful without reinventing /usr/bin/find in something with more support for structured data than shell scripting.)

3. aptitude search ~o
A quick explanation of “aptitude” for Ubuntu users:

  1. Debian invented apt-get
  2. apt-get didn’t get the lovin’ it deserved
  3. aptitude was invented as an apt-get that doesn’t suck and Debian decided to include it in the base install.
  4. The more popular aspects of aptitude eventually got added to apt-get
  5. Ubuntu decided that apt-get was enough and you have to sudo apt-get install aptitude if you want it.

Basically, aptitude is apt-get on steroids.

What does aptitude search ~o do? It lists all installed packages which aren’t backed by a repository. (Packages you installed using dpkg -i or gdebi, packages which are still installed after you removed the PPA, etc.)

I used it to identify which Humble Bundle games had been installed as .debs so I could replace them with tarballs and move them to my new games drive.

Posted in Geek Stuff | Leave a comment

Working around a MonoGame joystick crash

TL;DR: Try adding unset SDL_JOYSTICK_DEVICE to your game’s launcher script.

Have you ever encountered an error that starts out like this when trying to start a Linux port based on MonoGame?

Number of joysticks: 5
Number of buttons for joystick: 0 - 11
Number of axes for joystick: 0 - 8
Number of PovHats for joystick: 0 - 0
Number of buttons for joystick: 1 - 11
Number of axes for joystick: 1 - 8
Number of PovHats for joystick: 1 - 0
Number of buttons for joystick: 2 - 11
Number of axes for joystick: 2 - 8
Number of PovHats for joystick: 2 - 0
Number of buttons for joystick: 3 - 11
Number of axes for joystick: 3 - 8
Number of PovHats for joystick: 3 - 0

Unhandled Exception:
System.IndexOutOfRangeException: Array index is out of range.
  at Microsoft.Xna.Framework.Input.GamePad.AutoConfig () [0x00000] in :0
  at Microsoft.Xna.Framework.Input.GamePad.PrepSettings () [0x00000] in :0
  at Microsoft.Xna.Framework.Input.GamePad.GetState (PlayerIndex playerIndex, GamePadDeadZone deadZoneMode) [0x00000] in :0
  at Microsoft.Xna.Framework.Input.GamePad.GetState (PlayerIndex playerIndex) [0x00000] in :0
  [...]

It’s basically saying that it found five joysticks, then got their characteristics wrong, then died when trying to access item 5 out of 4 in the listing.

In my case, the problem was as follows:

  1. On Linux, there are two APIs for accessing joysticks. An old, deprecated, joystick-specific one, and the generic “any input device” API which has no concept of calibration.
  2. My first joystick device is always my 3DConnexion SpaceNavigator, which isn’t a joystick but has stupid USB HID tables which cause the Linux kernel to expose a useless joystick device as the first joystick on the system.
  3. Some games only listen to the first joystick.

My solution for a lot of games was to set this environment variable in my .xsessionrc to force SDL to see my XBox 360 gamepad as the first joystick and to access it via the calibration-aware /dev/input/jsX API rather than the “expect hardware to not need calibration” /dev/input/eventX API.

# Make sure SDL uses a joystick device which can be calibrated
export SDL_JOYSTICK_DEVICE=/dev/input/js3

Adding unset SDL_JOYSTICK_DEVICE to the launcher script for the game fixed it… at the risk of requiring joystick support to be had via antimicro (a joy2key-like utility).

Posted in Geek Stuff | Leave a comment

FocusWriter… whether or not you need “distraction-free”

Those who know me well know that I’m a bit of a paradox when it comes to writing. On the one hand, I do have issues with distraction and I do approve of the concept of separating composition and typesetting, but, on the other, I can’t use an ordinary distraction-free writing tool for two reasons:

  1. The sheer novelty of it sends me spiralling off into the “technology geek” side of my mind, which is generally quite disjoint from the creative side.
  2. They’re simply too spartan

There’s not much I can do about the former, but I may not need to. When I’m writing something like a blog post or an essay, it’s the “sitting down to write” part that’s the biggest problem. (My troubles with writing fiction seem more oriented around mentally modelling the characters and world… and I’m in the process of  using a mockup to refine a potential solution for that.)

However, the latter point definitely is something worth mentioning in more detail. Distraction-free or not, word processors optimized for composition rather than typesetting are a greatly under-explored market. LyX works beautifully for academic papers, textbooks, and the like, but tools intended for fiction seem to either be too minimal (notepad.exe with chrome trim) or too heavy (MS Word with more task-specific features).

Perhaps the most visually-distinctive examples of the former category are “distraction-free” word processors, like WriteRoom, which take over your whole monitor and present no GUI elements.

Originally, I just assumed that I disliked them because thought these simply weren’t for me but, after reading someone else’s blog post, it dawned on me that, no, WriteRoom just sucks and some people are better at living with it than others.

That blog post introduces FocusWriter, a cross-platform, open-source writing tool that’s primarily intended to be distraction-free, but can still be run in a window if you want (Alt+Enter to switch) and has so many author-oriented features that, even if you don’t need distraction-free, you’ll probably still want it. (Payment is optional. Just choose “$0.00″ from the Tip drop-down.)

Like most distraction-free writing tools, FocusWriter is highly themable [1] [2] [3] [4] and can be fine-tuned with “experience features” like playing typewriter sounds when you press keys.

However, where WriteRoom and its clones are the digital version of fancy stationery in a typewriter, FocusWriter asks and answers the question “What does the writer need to be more productive?”

Here’s the mix of answers it came up with:

  1. Minimize distraction without killing discoverability by using auto-hiding menus, toolbars, panels, and a statusbar.
  2. Not everyone needs a fullscreen writing tool. Allow the user to toggle windowed mode via F11 or the menu system.
  3. Keep the author “in the zone” by offering basic standard word processor functionality like rich text support. (Not everyone natively thinks in Markdown-like languages)
  4. Trust skilled authors to know to separate writing and proofreading. Don’t force them to open a whole other program just to run operations like spell check or search/replace.
  5. Provide a tab bar. “Distraction-free” doesn’t necessarily mean “single document”.
  6. Support saving and loading sessions. People who can only spare a few minutes at a time are authors too, as are people who juggle multiple projects.
  7. Acknowledge that some people may need extra help focusing. Offer tricks like greying out all but the line, three lines, or paragraph that the user is actively working on.
  8. Recognize that authors don’t always write in a linear fashion. Provide a jump-to-scene panel on the left and a scrollbar on the right.
  9. Help people meet their goals. Offer to track a daily goal, measured in minutes or words, and support tracking how many consecutive days the user has met their goals.
  10. Make it easy to check your word count, paragraph count, page count, character count, time, and progress toward your goal. Put them in a configurable statistics panel hiding at the bottom of the screen.
  11. Provide a timer system so users can let the outside world fade away without missing that upcoming appointment.
  12. Support auto-saving everything… right down to cursor position.
  13. Allow the user to export in plain text, RTF, DOCX, or ODT formats for easy compatibility with whatever their pre-readers may be using.
  14. Themes are a great way for authors to really get into the right mindset. They should be easy enough to create that anyone can do it. (Ink on Parchment? Typewriter on coarse paper? Phosphor on a VT100? A snowy field or futuristic slum? Google up a background image and a font, open up the “new theme” dialog, and go wild.)

There’s even a Portable Apps release of the Windows version for when you can’t get into the zone on your phone, but didn’t bring along anything else bigger than a thumbdrive.

In summary, don’t prejudge FocusWriter for its status as a “distraction-free word processor”. It’s a very elegantly designed, highly customizable word processor for creative projects that just happens to have distraction-free writing support as its most visible feature.

Posted in Writing | Leave a comment

Free resources for making games

I got a little carried away while assembling a list of game-development resources as an activity for a course I’m taking, so I decided to share them. Enjoy.

Everything listed is free enough (in both senses of the word) to be used in an open-source project and can be used to produce games which, at minimum, target Windows, Linux, and OSX. With a few minor exceptions, which are noted, all tools also run on any of those three.

Note: This is only a portion of the list I maintain for my own use. If you don’t see what you want, feel free to ask me to check my bigger, more cluttered private list.

Articles (Sample Platter):

Free Game Engines:

  • Godot
  • Panda3D (3D game engine developed by Disney specifically to enable high-quality games to be written in Python)
  • The Frogatto Engine (Anura) (Really impressive built-in level editing and dynamic reprogramming capabilities. Primarily targeted at 2D platformers, but can be repurposed.)
  • Sauerbraten and BananaBread (A Quake-like 3D game engine with as-you-play level editing and a WebGL port)
  • Various iD Tech engines that have been open-sourced
  • Spring Engine (Open-source 3D real-time strategy game engine)
  • EasyRPG (Open-source clone of the RPG Maker 2000/20003 editor and player. See MKXP for a clone of the RPG Maker XP runtime only.)
  • Adventure Game Studio (Open-source editor and engine for 2D games in the style of King’s Quest and Monkey Island. Editor runs on Windows. Engine ported to all major platforms.)
  • Ren’Py (The most popular engine for English-language visual novels and related types of games)
  • TADS (The most advanced engine for interactive fiction (text adventures), supporting rich text, illustrations, ambient sounds, hyperlinks, etc. The IDE is is Win32-only, but a fully-portable command-line toolchain is available and the IDE can be run in Wine if you use winetricks to install IE6.)

Free 3D Engines and Game Frameworks:

  • OGRE 3D (Highly-extensible, modular 3D engine as used by games like Torchlight and The Book of Unwritten Tales)
  • Irrlicht (3D engine used in proprietary games like Octodad and open-source ones like SuperTuxKart)
  • SDL 2.0 (The big name in providing a portable alternative to DirectX. With add-ons like SDL_mixer, the Render API provides a higher-level 2D experience comparable to Allegro)
  • HaxeFlixel (Port of the Flixel 2D engine from ActionScript to Haxe, a statically-typed derivative which compiles to SWF or native code)
  • Moai SDK (used by Broken Age. A.K.A. The DoubleFine Adventure)
  • MonoGame (Open-source XNA 4.0 clone for C# games. Used to port games like Bastion, Escape Goat, and Fez to non-Windows OSes. See MonoGame-SDL2 for best Linux backend.)
  • LWJGL (Portable Java game library used by Minecraft.)

Free Resources:

Relevant Steam Dev Days Talks:

Tools:

  • ASEprite (Allegro-based, open-source sprite editor. $10 for pre-built or compile it yourself for free)
  • Audacity (Free, open-source, cross-platform audio editor)
  • Git Extensions (An easy-to-install Windows distribution of the Git revision control system which provides comprehensive GUIs.)
  • Krita and MyPaint (Free, open-source digital painting tools which compete with Corel Painter and SAI… unlike GIMP which is even more specialized as a photo-retoucher than Photoshop.)
  • LMMS (Free, open-source, cross-platform music-composing tool. Ardour is even more powerful but only works on Linux and OSX and has a bit of a learning curve.)
  • Qt Creator (The free, portable, mature C/C++ IDE that Valve apparently prefers.)
  • TileEd (Free, open-source level/map editor for when you’re building your own game engine)
  • VirtualBox (Free, open-source competitor to VMWare. Has guest 3D drivers, which make it an easy way to quickly test new game builds on other platforms.)

Tools (3D):

  • Blender (Free, open-source professional-quality 3D modelling tool with built-in game engine and non-linear video editor.)
  • GtkRadiant and QuArK (Level editors for games based on the various iD Tech engines that have been open-sourced over the years)
  • MakeHuman (Free, open-source tool for generating humanoid 3D models quickly and easily)
  • ngPlant, Arbaro, Ivy Generator (Free, open-source, parametric generation of 3D plant models)
  • Terraineer, HME, and Picogen (Cross-platform, open-source terrain heightmap generators and/or editors. Geomorph and Terraform also exist, but they’re Linux-only.)
  • Wings 3D (Free, open-source subdivision modelling tool which may be easier to learn than Blender when that’s all you need.)

Free, Open-Source Installer Generators:

  • NSIS (As used by many many Windows programs and games)
  • InnoSetup (The other big, free installer generator. Used by all GOG.com Windows releases)
  • install.sh for Linux tarball releases (My own creation, so you can ask me for help with it. Used by the Linux releases of games like SteamWorld Dig and Desktop Dungeons)
  • Mojo Setup (For when you really need a binary Linux installer package… but there’s no “unpack it without running the install scripts” tool like cabextract or innoextract for it, so expect to piss off people like me if this is the only option you offer.)

Services Free to Projects Which Open-Source Their Code on GitHub:

Enjoy. :)

Posted in Geek Stuff | Leave a comment

Recommendations for an Interactive Fiction Engine

If you’re writing a piece of interactive fiction (A.K.A. a text adventure game),writing your own engine is the last thing you want to do. (That’s no fun. The fun is in providing off-the-wall responses to crazy instructions.)

Instead, there are three engines I strongly recommend that you consider using. All are open-source, all permit you to redistribute and sell your creations freely and, while they are quite different in what they do and don’t offer, all have plenty of advanced features that would be a pain to reinvent, like graph-drawing IDEs, text parsers, accessibility for the visually impaired, etc.

I’ll go in the order I recommend that you consider using them:

Twine

Twine is a purely mouse-driven system (no text parser) with Choose Your Own Adventure-style gameplay as its primary focus. However, it does have macros and variables, it is extensible, and you will never find anything simpler or easier to create and share with.

Twine 1.x uses a native Windows or MacOS editor which graphically visualizes the structure of your story. Twine 2.0 (in beta as of this writing) moves the editor into the browser so installing your own copy is optional and Linux authors aren’t left out.

An exported Twine story is simply a TiddlyWiki 2.x HTML file that has been given an extreme makeover, which means that it requires no special hosting. Put it in your Dropbox, attach it to an e-mail, or put it on a thumbdrive. If the reader has a web browser, they can use it.

This also means that each page/passage/screen/location in your story is simply a series of pages, __written__ –in– ”TiddlyWiki” //markup//, and connected by [[wiki links]]. (Embedded images are supported)

Taking proper advantage of its TiddlyWiki underpinnings, Twine provides a selection of TiddlyWiki <<macros>> and predefined JavaScript functions for things like manipulating variables and displaying different content depending on the values of those variables. It is also easy to include custom CSS or JavaScript.

A simple but comprehensive tutorial is available with plenty of screenshots for the 1.x series.

Given how low-friction Twine is, I’d suggest using it to prototype anything that can be implemented purely using mouse input, and then copying your text to TADS (which also supports HTML with hyperlinks) if you outgrow it.

Free hosting for your stories is available at Philomela, Adventure Cow, and any service which lets you share an HTML file without modifying its contents, such as Neocities, Dropbox, or your GitHub Pages blog.

Here are a few examples of what people have built with it:

TADS

TADS (short for Text Adventure Design System) is an advanced programming language, engine, and development environment for text adventure games. They also provide a site named the Interactive Fiction Database (IFDB for short) which provides free hosting for non-pornographic games and allows people to play them in the browser if you export them in the right form.

Writing your game in TADS has the following big advantages:

  1. A ready-made engine with a highly advanced text parser, a bundled library of 150+ predefined verbs, and a world model that allows it to infer things like “the room should go dark if you put the only light source in a box and close it”.
  2. HTML TADS” multimedia support so you can include headings, illustrations, text formatting, horizontal rulings, block quotes, ambient sounds, etc.It also allows you to hyperlink words like “bottle” to commands like “take bottle” to enable a certain degree of mouse interaction.
  3. A simple C++/ActionScript-like language with declarative extensions that make it easy to rely on the engine to understand concepts like picking up objects and moving from place to place.To quote the TADS website, When we designed TADS, we started by asking why it’s so difficult to write IF with a mainstream language like C++ or Javascript. We applied the answers we found to the design of a new language. The result looks a lot like C++ and Javascript, but has many differences, small and large, that make it better suited for IF. 
  4. A Flash-like “portable bytecode and platform-specific runtimes” approach to distributing games with at least one open-source runtime per platform for Windows, MacOS, Linux, DOS, AmigaOS on PPC, BeOS, and jailbroken Kindles, plus an in-browser solution.(Though it does require you to set up some server-side componentry if you are self-hosting rather than relying on IFDB.)
  5. Fully open-source with command-line compilers for all major platforms and an IDE for Windows which can generate both EXE installers and the TADS equivalent of Java JAR files for you with one or two clicks. (And it includes offline copies of the quickstart guide, tutorial, and various reference manuals)
  6. As of TADS 3, you can override just about any default behaviour to make as complex and fancy a UI as you want. For example:
    • One screenshot shows an arcade game where text mimics graphics.
    • The documentation for the advanced windowing features discusses an example with a fixed status line, fixed “picture of the location” pane, fixed compass, and scrolling text pane.
  7. They’re working toward network multiplayer support. (The in-browser option has network primitives but “just ask for it and you’ve got a MUD” isn’t an option quite yet.)

As they say on TV Tropes:

Examples of games with actual good parsers include The Hobbit and anything by Infocom or Legend. Ironically, that includes some of the oldest adventure games; many of the newer ones tried to reinvent the parser wheel. The TADS (Text Adventure Development System) runtime is particularly good at such reinvention — not only can you actually get ye flask, TADS allows to choose between multiple ye flasks, and will ask which one thou actually wantest.

Here’s the “starter game” from the quick start guide so you can get an idea for how much it does for you.

         #include 
         #include <en_us.h>

         gameMain: GameMainDef
           initialPlayerChar = me
         ;

         versionInfo: GameID
           name = 'My First Game'
           byline = 'by Bob Author'
           authorEmail = 'Bob Author <bob@myisp.com>'
           desc = 'This is an example of how to start a new game project. '
           version = '1'
           IFID = 'b8563851-6257-77c3-04ee-278ceaeb48ac'
         ;

         firstRoom: Room 'Starting Room'
           "This is the boring starting room."
         ;

         +me: Actor
         ;

Connecting rooms together is as simple as writing west = firstRoom in one and east = secondRoom in another.

The main downside is that, because IFDB doesn’t allow pornographic content, a pornographic text adventure like Corruption of Champions must be self-hosted. (And, as I mentioned, self-hosting the “play in browser” option is a bit involved.)

Now for the other option:

Inform 7

Like its predecessors, Inform 7 compiles to bytecode for Inform’s venerable Z-machine runtime but can also produce bytecode for the Glulx engine, a modern successor which removes many of the system’s limitations.

Like TADS, multiple open-source runtimes are available and the IDE is open-source as well. However, unlike TADS, Inform 7 games generally have minimal text parsers and no support for anything beyond what you’d see in notepad.exe.

However, there are four reasons I recommend Inform 7 to people who don’t want to use TADS:

  1. It has a more impressive IDE than TADS, the Inform 7 IDE is available on Windows, MacOS X, and Linux platforms and has various visualizations that help you to better understand the structure of your game.
  2. There is a pure Javascript runtime that’s directly supported by the IDE, so producing “play in the browser” versions is ridiculously easy.
  3. Thanks to playfic.com, you can write, share, and play Inform 7 games completely in your browser.
  4. It has a “plain english” syntax. (I think this is a downside, but some people apparently prefer it.)

For comparison with TADS, here’s Inform 7’s answer to “Hello World”:

"Hello Deductible" by "I.F. Author"

The story headline is "An Interactive Example".

The Living Room is a room. "A comfortably furnished living room."
The Kitchen is north of the Living Room.
The Front Door is south of the Living Room.
The Front Door is a door. The Front Door is closed and locked.

The insurance salesman is a man in the Living Room. "An insurance salesman in a tacky polyester suit. He seems eager to speak to you." Understand "man" as the insurance salesman.

A briefcase is carried by the insurance salesman. The description is "A slightly worn, black briefcase." Understand "case" as the briefcase.

The insurance paperwork is in the briefcase. The description is "Page after page of small legalese." Understand "papers" or "documents" or "forms" as the paperwork.

Instead of listening to the insurance salesman for the first time:

    say "The salesman bores you with a discussion of life insurance policies. From his briefcase he pulls some paperwork which he hands to you.";
    move the insurance paperwork to the player.

In essence, both TADS and Inform 7 are specialized programming systems with first-class tooling but TADS developers focused on giving you more freedom to create rich experiences while Inform 7 focused on trying to make the existing spartan experience accessible to a wider, less technical population of authors.

Personally, I think Inform 7’s plain English syntax is counter-productive because no programming language can understand the full breadth of English grammar and that conflation makes it harder to fully learn what the language will and won’t allow when compared to a purely artificial syntax like the ones used in TADS and older Inform versions.

Other engines with text parsers do exist, but TADS, Inform, and ADRIFT are the most popular by a huge margin (very important for ensuring plenty of good documentation and community support) and ADRIFT costs money.

All in all, my advice is to use Twine for mouse-driven stuff and TADS for stuff requiring a text parser. They’re both proven solutions that are only going to get better and you should never underestimate the benefits of having a solid, versatile foundation with plenty of room to grow.

(If you know enough JavaScript you can extend Twine to do anything and TADS, while not a full web browser, has a smart, extensible text parser and a renderer that allows you to enhance your text with custom typesetting, illustrations, fixed UI elements, and more.)

P.S. If you want mouse-driven and graphical instead, you probably want either Ren’Py or Adventure Game Studio. There’s also EasyRPG if you want an open-source RPG Maker clone.

Posted in Geek Stuff | Leave a comment

Non-interactive batch-deleting in TaskWarrior

Well, given how much time I spent squashing bugs on my system after updating it, I missed quite a few instances of daily routine tasks (eg. doing my exercises) in TaskWarrior.

Given that I don’t have a GUI installed and TaskWarrior’s support for temporarily disabling the “are you sure?” confirmation is broken, I decided to whip up a tiny little expect script.

Here it is in case anyone else ever wants to batch-delete easily.

Posted in Geek Stuff | Leave a comment