thinking about autocomplete - feedback would be nice

13 views
Skip to first unread message

Stephen Lavelle

unread,
Mar 8, 2026, 11:40:16 AM (13 days ago) Mar 8
to PuzzleScript

I've been working on autocomplete today, adding more functionality to the direction classes


Basically, I hard code a bunch of suffixes, and if you use the first one, then you are presented with the rest as autocomplete options.

var DIRECTIONAL_PAIRINGS = [
["Up", ["Down", "Left", "Right"]],
["UP", ["DOWN", "LEFT", "RIGHT"]],
["up", ["down", "left", "right"]],
["_u", ["_d", "_l", "_r"]],
["_U", ["_D", "_L", "_R"]],
["North", ["South", "West", "East"]],
["NORTH", ["SOUTH", "WEST", "EAST"]],
["north", ["south", "west", "east"]],
["_n", ["_s", "_w", "_e"]],
["_N", ["_S", "_W", "_E"]],
];


Example of autocomplete as it is after an afternoon's work:

Image


So I was thinking of stupid differences, like having NSEW rotate sprites but UDLR mirror (not a fan of weird differences like this, but maybe it make sense).


But I'm also thinking it might be better to just settle on fixed suffixes rather than trying to be magical, and to carefully document them.

I like the idea of keeping the syntax fully compatible with existing puzzlescript, and this stuff only existing in the form of autocomplete (rather than having formalized suffixes like some puzzlescript variants IIRC have, using : or whatever as a separator). 

It increases complexity a bit for those who can benefit from adding it to their mental modal, but it's not necessary, and if you are just looking at code you don't know it's a thing.


Now, a big win from trying to formalise this might be in auto-expanding rules, like, when you start typing 'down' on the second line the compiler will recognise what you want and auto-complete the remaining three lines (or maybe just the next line?).


up [ > player | ] -> [ tail c_up | c_down player ]
down [ > player | ] -> [ tail c_down | c_up player ]
left [ > player | ] -> [ tail c_left | c_right player ]
right [ > player | ] -> [ tail c_right | c_left player ]


if we're smart about this we could also sensibly deal directions and stuff like 'horizontal'/'vertical'. It warrants a test-suite though.


A point of confusion would be dealing with when up/down should be mirrored vs rotated (also a problem with sprite rotation tbh).  Terrible idea: if you begin the second line with right rather than down, then autosuggest four rotations in URDL order, otherwise do it with UDLR mirrored versions (with L being a rotated version of U?).


I'd be interested in hearing thoughts from other people about this - what might be good, what might be bad, what other possibilities there might be. (Especially people who have experience with puzzlescript forks, to learn how they do things).


(

issue duplicated on the github:

https://github.com/increpare/PuzzleScript/issues/1127

)

Reply all
Reply to author
Forward
0 new messages