While I’ve been away from my computer, I’ve been working on the code for a side project on my phone. Working on a phone has its unique challenges.
I also bit off way more than I could chew. It’s an open world with 133 distinct locations you can visit. Each one is a port (or similar to a port) with a range of standard activities, like Sid Meier’s Pirates! or … actually it’s literally just Sid Meier’s Pirates but fantasy and with choicescript.
Having 133 locations is really annoying – copying and pasting stuff on a phone takes forever to do and is super fiddly. So, I tried to figure out a way to semi-automate it.
First, I created exactly one port to see how the code should look:
*label rosewharf
[b]Rosewharf, Ocrya[/b]
Rosewharf earns its name from the thickets of bright red roses that choke the hills in a bloody, prickly half-circle around the docks. The townsfolk all wear thick leather gloves.
*label rosewharf_hub
*choice
*disable_reuse # Tavern.
*gosub tavern
*disable_reuse # Guild.
*gosub guild
*disable_reuse # Market.
*gosub market
*disable_reuse # Shipyard.
*gosub shipyard
# Set Sail.
*return
*goto rosewharf_hub
There are some other stuff like specific NPCs and events that show up on random timers but that’s pretty much the bones of it.
I could copy and paste that whole thing 132 times (or 9 times if I keep recopying and repasting everything) and then individually replacing each label and goto and piece of flavour text with the entire list one by one but that would take forever.
Luckily I already have a google sheet with all the information I need on it.
So, here’s what I actually did:
- On Sheets, figure out how to sort locations alphabetically and also include other columns in the sort. Apparently you select the column and sort from there. Took me a bit to sort it out, pun intended.
- Copy the alphabetically-sorted column of names.
- Copy into Docs. Select everything. Try to find the Sentence Case toggle and realise it’s not there.
- Copy into Microsoft Word for mobile. Immediately hate the interface. Press on anyway. Paste in and realise it’s pasted as a table instead of text. Try to select and delete or undo but the interface is too buggy. Close the program. Restart. New document. Paste as plain text.
- In Word, make everything lowercase so I can use it as a label later. Also find replace every space with an underscore. That’s my label list. Call it {port}.
6.Create a new column in Sheets. - Select all. Copy into the blank column in Sheets. Motherfucker, it’s added a full paragraph after every row. Undo. Paste into Notes. Recopy from Notes into Sheets. Done, perfect. Lines up.
- Create a bunch of columns in Sheets: *label, {port}, Port, literally just a comma, Country, *label, {port}, _hub, *goto, {port}, _hub. Autofill everything.
- Copy all back into Word. Shudder at the interface.
- Replace the tabs with a space
- Replace " ," with “,”
- Replace " _hub" with “_hub”
- Paste into the ChoiceScript interface.
- Creates this for each port:
*label ziz_iggar Ziz Iggar, Kuwiarus *label ziz_iggar_hub *goto ziz_iggar_hub
And now all I have to do is … manually go through each port, one by one, and space them out such that they look like this:
*label ziz_iggar
Ziz Iggar, Kuwiarus
*label ziz_iggar_hub
*goto ziz_iggar_hub
… which creates 133 infinite regression loops in my code. So once I’m done all that I can fill in all the ports by …
… copying and pasting 133 times.
Well, they’ve all got different stuff in them so I’d have to manually go into each one anyway.
But yeah that was the annoying problem I “solved” for myself today!


