Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro capture #2179

Open
byorgey opened this issue Oct 14, 2024 · 5 comments
Open

Macro capture #2179

byorgey opened this issue Oct 14, 2024 · 5 comments
Labels
Z-Feature A new feature to be added to the game.

Comments

@byorgey
Copy link
Member

byorgey commented Oct 14, 2024

Is your feature request related to a problem? Please describe.
When exploring a world or challenge scenario manually, I often execute a series of commands that I later want to turn into a definition.

Describe the solution you'd like
I'd love some kind of "capture macro" shortcut which takes the n most recent REPL inputs and... somehow spits them out in a definition suitable for copy-pasting into a .sw file. Like maybe it just sticks the definition in the clipboard? I also don't really know what n should be, or if it should be configurable at all.

@byorgey byorgey added the Z-Feature A new feature to be added to the game. label Oct 14, 2024
@kostmo
Copy link
Member

kostmo commented Oct 15, 2024

See also #821

@byorgey
Copy link
Member Author

byorgey commented Oct 15, 2024

See also #821

Ah, I had forgotten about that! That will definitely help me in the short term. Longer term I still think this could be a nice feature to have, which would do a similar thing but in a more user-friendly way.

@xsebek
Copy link
Member

xsebek commented Oct 15, 2024

@byorgey would it not be best to pretty-print the base environment to a file? You could then remove the unnecessary parts.

@byorgey
Copy link
Member Author

byorgey commented Oct 15, 2024

@xsebek That would be useful too, but it's different than what I'm proposing here. I am concerned with the situation where you have typed a sequence of commands at the REPL, but you have not used def to create a definition. I want to extract that sequence of commands into a definition. For example, suppose you typed

> move
> move; move
> turn left
> m10
> turn right
> grab

and then you hit the "capture macro" shortcut; it would place the following in your clipboard, suitable for pasting into a .sw file:

def macro6 =
  move;
  move; move;
  turn left;
  m10;
  turn right;
  grab;
end

Or something like that, anyway.

@xsebek
Copy link
Member

xsebek commented Oct 15, 2024

Ah, I copy it from history after quit:

tail -n 6 ~/.local/share/swarm/history

It would be nice to copy a selection of REPL lines in the game, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-Feature A new feature to be added to the game.
Projects
None yet
Development

No branches or pull requests

3 participants