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

Macros #8

Open
smalewski opened this issue May 26, 2020 · 7 comments
Open

Macros #8

smalewski opened this issue May 26, 2020 · 7 comments

Comments

@smalewski
Copy link

I was just thinking of developing something that allows me to automate a little my ACNH experience. But instead of writing my own I think I can help you with this.
I'll be happy to make a DSL for writing and running macros.

Do you have any strong opinions on the subject?

@juharris
Copy link
Owner

Thanks for asking! Yes I have lots of plans and opinions for macros, especially for AC. I'd actually like to implement some of these fake QOL updates by suggesting default macros to use based on the content on your screen. I'm just waiting to get my video capture device before testing more.

As for a DSL, I've outlined our API spec that is written with lots of consideration for people writing macros: https://github.com/juharris/switch-remoteplay/blob/master/server/README.md#api
I suggested you use and update that.

@smalewski
Copy link
Author

That's a really cool video!

Reading the API it appears to me that the parsing should be done by the client (so it can take care of the wait instruction). I think that may unsync the sequence.

I mean a d, (some instructions), wait 100, a u would probably not wait at all if it takes more that 100 ms for the server to execute (and receive) those instructions. Should the server take care of that?

Also I'm thinking of adding some control structures, like a repeat n instruction.

@juharris
Copy link
Owner

Wait

Yeah I'm not completely sure who should do the wait but I am leaning more towards the server doing it:

advantages for server:

  • server already has command parsing logic
  • it would be tricky for the client to parse and run complicated command with sequences and conjunctions
  • more reliable in case the client has an error sending the command
  • server can handle waits that might have already happened since it can take time to send a command. e.g. 'wait 20' is probably useless and we don't need to wait at all

advantage for client:

  • maybe more reliable that the wait actually happens and doesn't cause extra threads to stay running on the server

Loops

Yes I've also been thinking of a good looping syntax. For loop I want to support:

  • loop n times
  • loop forever
  • loop until condition (we don't even have conditionals in our DSL yet so I'm not sure how this one will look)

I was thinking of supporting: 'loop N {EXPRESSION} where:

  • N: a number or 'FOREVER'
  • EXPR: any expression supported by our DSL

@juharris
Copy link
Owner

juharris commented May 26, 2020

BTW As for security of these things, I'm not so worried since I hope people don't really expose their servers too publicly but I have lots of plans for various security features and configuration to enable/disable them. For example, we would have options to allow/ban infinite loops and an option for max N for a loop.

@smalewski
Copy link
Author

I think repeat is a very expressive keyword for a loop that can repeat N or Forever. Also I'm thinking, to simplify the writing of macros, to use a more verbose syntax allowing only one instruction per line and using indentation for sub blocks.
For example:

s left down && s left right
repeat 8
    a d
    wait 100
    a u

It's a bit more wasteful with the character count, but not that much. Braces would be ok too.
This would mean that proper parsing is needed, thought.

For the conditionals we need some kind of expression first. Maybe we should wait for the video capture to really know which kind of interesting conditions exist.

@juharris
Copy link
Owner

I don't have strong feeling for loop vs. repeat but I've seen loop in AutoHotkey.

Yeah that multiline style is nice but I image people would write macros within our client page in the browser and so the actual API styling would be handled elsewhere. Although I guess we should support loading macros from a file so this styling does matter. Even though I do like Python, I think for non-devs, we shouldn't really rely on just whitespace to parse commands, so have braces is safer than only whitespace/indents. Yeah character count isn't great but I think that's ok for macros. I mainly want to make sure that natural input from keystroke, controllers, etc. is as fast as possible.

@juharris
Copy link
Owner

juharris commented May 26, 2020

BTW you should DM me on Twitter and I can add you to our Discord server. LMK if you don't have Twitter: https://twitter.com/jusharris

juharris pushed a commit that referenced this issue Jun 9, 2020
Relates to #8
juharris added a commit that referenced this issue Jun 19, 2020
Macros: save, edit, and delete. They're stored in your browser.
Relates to #8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants