[Script] - Ultima 4, 5, 6

Författare Svar
daemonburrito Wednesday 3 September 2014 at 3:03

First attempt at a script... Based on MindLikeWater's Ultima 1,2,3, with a workaround for the bug in All three directories have spaces, and to work around the bug I create symlinks.


First pass without the meta or the pngs. Also available for comments/changes on github: Tips welcome. Also let me know if I'm doing formatting, etc. right for this forum.


#!/usr/bin/env bash
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"


TITLE=" - Ultima 4, 5, 6"
DEVELOPER="Origin Systems / Electronic Arts"
INSTALL_DIR="Ultima Second Trilogy"
GAME_DIR1="Ultima 4"
GAME_DIR2="Ultima 5"
GAME_DIR3="Ultima 6"

SHORTCUT_NAME1="Ultima 4: Quest of the Avatar (Bundled)"
SHORTCUT_NAME2="Ultima 5: Warriors of Destiny"
SHORTCUT_NAME3="Ultima 6: The False Prophet"


POL_SetupWindow_presentation "$TITLE" "$DEVELOPER" "$GOGID" "daemonburrito" "$PREFIX"

POL_Wine_SelectPrefix "$PREFIX"
POL_Call POL_GoG_install

cat <<_EOFCFG_ >> "$WINEPREFIX/playonlinux_dos.cfg"

[ "$POL_OS" = "Linux" ] && echo "render_scaler=hq2x" >> "$WINEPREFIX/playonlinux_dos.cfg"

POL_SetupWindow_wait "Moving game dirs to shortened names" "$TITLE"
# workaround for shortize bug
cd "$WINEPREFIX/drive_c/"

POL_Shortcut "GOG Games/$INSTALL_DIR/$GAME_DIR1_SHORT/$EXEC1" "$SHORTCUT_NAME1" "$SHORTCUT_NAME1.png" "" "Game;RolePlaying;"
POL_Shortcut "GOG Games/$INSTALL_DIR/$GAME_DIR2_SHORT/$EXEC2" "$SHORTCUT_NAME2" "$SHORTCUT_NAME2.png" "" "Game;RolePlaying;"
POL_Shortcut "GOG Games/$INSTALL_DIR/$GAME_DIR3_SHORT/$EXEC3" "$SHORTCUT_NAME3" "$SHORTCUT_NAME3.png" "" "Game;RolePlaying;"

exit 0

Ändrat av Tinou

petch Wednesday 3 September 2014 at 23:43

     Hi daemonburrito,

Your script looks quite ok, and having the games myself I could even check that it does the job ;)

Let's go on with the review:


While I understand the urge for modern developers to put symbolic names on things, and agree that it's a good thing on most environments, I'm not sure sure of the benefit in short shell scripts:

- you can't make them immutable, so they're variables used as constants;

- unless you use set -u you may not notice typos in variable names, so it makes code more brittle;

- functions can inadvertly override variables (unless they carefully use "local", which is not always the case);

- benefits are not so obvious for 20 or 30 lines of code.

So I'm not very convinced by this practice in the context of PlayOnLinux install scripts.

POL_SetupWindow_wait "Moving game dirs to shortened names" "$TITLE"

Messages to the user should be enclosed in $(eval_gettext '') to handle localization. However creating 3 symlinks is so far that the message may be better simply be left off.


POL_Call POL_GoG_install sets $GOGROOT to the base GOG install directory, so this can be simplified as



cd "$WINEPREFIX/drive_c/"

That line is not necessary, POL_Shortcut take either filenames or paths relative to drive_c, no matter the current directory.

Just one last note,

#!/usr/bin/env bash

That would mean that what follows is a Bash script, and that if you set the executable bit on it, you'd like Bash to be used to actually interpret it.

But while it's technically a Bash script, it's actually a PlayOnLinux script, that uses Bash as an extension language. Having it executed straight from Bash won't get you anything (the first test will just terminate the script right from the start). So it's rather just misleading.

If anything, you could say that you want it to be interpreted by playonlinux-bash, and that would actually work.

But that's usually not how PlayOnLinux script are evaluated, so this first line should better be omitted.


That's it for me, feel free to submit the script to the official repository!



petch Wednesday 3 September 2014 at 23:51

One other thing I noticed, functional this time: GOG uses different DOSBox settings for games, for example for Ultima 6 they use


It's not very simple to replicate this with PlayOnLinux DOSBox support, that expects one game per virtual drive, but this can be done using wrapper batch scripts that use CONFIG -set statements.

See for example the Alien Breen and Tower Assault script, ll. 75-81.


Ändrat av petch

petch Thursday 4 September 2014 at 0:12

[...] with a workaround for the bug in All three directories have spaces, and to work around the bug I create symlinks.

That one is interesting too, if you want to look into it, because the problem is not exactly the spaces: actually handles "GOG Games" or  "Ultima Second Trilogy", at the levels above, just right. You can also run its unit tests (, next to it) that contain tests involving spaces.

The problem is that once there's more than one name side by side that have the same name short prefix, the renaming mechanisms inside DOSBox stop behaving as a function: "Ultima 5" gets translated to "ULTIMA~2" only because there's also an "Ultima 4" right next to it, or something like that. That looks very complicated to get right.

daemonburrito Thursday 4 September 2014 at 5:29

Regarding the shortize bug... you are right, and that is what I meant to express. All directories end up as "ULTIMA~1" to shortize. By the spaces causing it, I mean that if there were no spaces, shortize would not try to fix them ;). The problem is only in the creation of the shortcuts... All three will end up pointing to the same directory.

Thank you for the tip about Ultima 6 and splitting up games from multi-installers into multiple prefixes. It's probably worth it for me to try to get that right in the next iteration, and the technique is probably going to come in handy for the next couple of collections (the old Sierra games, which coincidentally also have problematic directory names).

Thanks especially for the notes on the idioms. I was doing as the Romans do from what I've seen, and I appreciate the guidance. Also, thanks for your github wiki!

Oh, and one last question: Where is the official repo? Thanks again.

daemonburrito Thursday 4 September 2014 at 5:31

Oh crap, I found the sticky regarding submission, sorry, nm.smiley

petch Thursday 4 September 2014 at 14:06

Thank you for the tip about Ultima 6 and splitting up games from multi-installers into multiple prefixes.

It's not using multiple prefixes, just using the fact that many (most?) DOSBox settings can also be modified dynamically; Hence we can set common DOSBox settings at the prefix level, and adjust the specific settings for each game using dynamic settings.

daemonburrito Thursday 11 September 2014 at 3:55

Sorry for the delay, day job coding interfering with gaming.

I wrote a Python script that I thought you might find handy, as it's inspired by the batch file trick you showed me. I'm using it to make much-improved POL scripts with perfect-ish dosbox settings (or at least in perfect agreement with GOG in their multi-packs).

Just a little thing to compare any number of configs and return the common settings, and a list of unique settings. Right now, it just pretty-prints the Python dict, but I'll add support for other output formats soon, including ini and a format that can be pasted into the heredoc, as in the example.

Ändrat av daemonburrito

daemonburrito Saturday 13 September 2014 at 21:30

Updated, and art done:

Pretty much the same, but with batch file launchers with individual dosbox configs, and all of your other suggestions.

daemonburrito Saturday 13 September 2014 at 21:58

Something seems to have gone horribly wrong with submitting the script:

I thought I was following the directions here, but I didn't see where to save the script and clicked "Edit". So the submission is empty... Very confused. Was I supposed to paste the code into the "Description" editor?

Saddening, would love to contribute.

EDIT: Posted the code in an update. Would still love to know how to do it right or fix it.

Got help on irc, uploaded assets to:

Ändrat av daemonburrito

petch Tuesday 16 September 2014 at 22:09

I validated the script; For the icons I used the "original" VGA ones, because downscaled GOG ones are not really recognizable. I don't know what to use for installer icon, I thought about downscaling the same image used for "top" gfx, but 22x22 is small ;)

About DOSBox setup, I think something much shorter should be possible:

- settings are default values, hardcoded in the DOSBox support; So those values are optional in conf files;

- some settings are "decorative": if [gus] gus=false is set, no other gus related setting is effective;

- Ultima 5 and Ultima 6 settings are the same, or at least very close; So their settings can be used as defaults, and only use CONFIG -set in the Ultima 4 wrapper script.

But anyway, that's an optimization only...

petch Tuesday 16 September 2014 at 22:15

By the way, if you're already familiar with git, I actually manage the GOG scripts using github too; And I have the resources stored in the same layout as the sftp server, so that I can update them with just one command.

For example for this script the commit looks like:

So sending resources could be a simple merge request :)