chapelr / harlowe-macro-api Goto Github PK
View Code? Open in Web Editor NEWAdds an accessible, simplified framework to Harlowe for creating custom macros in JavaScript.
Home Page: https://harlowe.twinelab.net/
License: The Unlicense
Adds an accessible, simplified framework to Harlowe for creating custom macros in JavaScript.
Home Page: https://harlowe.twinelab.net/
License: The Unlicense
Do you think it would be possible to create a Steamworks API Macro using this?
It seems like basic macros that return stuff are launching themselves at hooks. Will investigate.
A gist with the source and documentation can be found here.
(If the documentation needs to be reworked to fit the rest of the site I can assist, but this is a pretty complicated macro to document.)
I found myself with a bunch of little complex calculations I needed to run regularly throughout my game, and I was able to halfway fake macros by making code-only passages that would read and write global variables to accept arguments and return results, and I could then (display:)
the passage to run it.
That ended up being a hot mess, because the arguments and results would stick around forever as global variables, and the syntax was clumsy and verbose. Also, I had to use some complicated self-replacing hooks to make sure to not accidentally mess up the spacing and formatting on the calling passage.
I used this framework to hack into Harlowe ever so slightly to create real macro passages. This adds a (macro:)
macro that accepts a suitable passage name (one that's been tagged with macro
) and any arguments. The macro passage will immediately run off-screen, with the arguments array available in _args
and the ability to return a value in _result
. Everything is nicely isolated, and shouldn't interfere with the calling passage's formatting or variables.
For some additional sugar, tagging a passage with both macro
and auto-macro
will turn the entire passage into a first-class macro on startup, so you can just use (macro-name: <...arguments>)
instead of (macro: "macro name", <...arguments>)
.
More detailed info and caveats are available in the gist itself.
More examples and maybe an example project.
I can look at Custom Macros for SC 2 for ideas of macros to port over.
Basic ideas that might be neat:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.