-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Dynamically loadable language libraries #248
Draft
unthingable
wants to merge
4
commits into
hundredrabbits:main
Choose a base branch
from
unthingable:sborca
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,11 @@ | |
<script type="text/javascript" src="scripts/lib/theme.js"></script> | ||
<script type="text/javascript" src="scripts/lib/history.js"></script> | ||
<script type="text/javascript" src="scripts/lib/source.js"></script> | ||
<script type="text/javascript" src="scripts/core/library.js"></script> | ||
<script type="text/javascript" src="scripts/core/library/library.js"></script> | ||
<script type="text/javascript" src="scripts/core/library/base.js"></script> | ||
<script type="text/javascript" src="scripts/core/library/default.js"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the uglier parts. Is there a better way to organize and load these so that new definitions can be added without modifying Ideally this would be user loadable. |
||
<script type="text/javascript" src="scripts/core/library/orca157.js"></script> | ||
<script type="text/javascript" src="scripts/core/library/sborca.js"></script> | ||
<script type="text/javascript" src="scripts/core/io.js"></script> | ||
<script type="text/javascript" src="scripts/core/operator.js"></script> | ||
<script type="text/javascript" src="scripts/core/orca.js"></script> | ||
|
@@ -30,7 +34,7 @@ | |
|
||
client.install(document.body) | ||
|
||
window.addEventListener('load', () => { | ||
window.addEventListener('load', () => { | ||
client.start() | ||
client.acels.inject('Orca') | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Orca language is a "library" of operators (everything that is not a command) that together define its behavior. Orca has the ability to dynamically load and combine multiple operator libraries at runtime, effectively allowing you to reconfigure the language. For example, you may want this for playing older compositions that are no longer compatible with the current Orca, or to experiment with alternative operators without affecting mainline Orca. Language reconfiguration lets you tailor the language to your individual composition. | ||
|
||
Orca starts with a `default` library, additional libraries can be loaded and combined via the `lang` command. Library loading is incremental, that is, operators defined in the new library are added to runtime, replacing existing operators. A given library may define all operators or only some. To completely clear the runtime library and start with the blank slate use the `clr` library. | ||
|
||
## Available libraries | ||
|
||
"Complete" means you get a fully functioning Orca by loading just that library, "incremental" means it only defines a subset of operators and you need something loaded before that to get a full Orca (usually `default`). | ||
|
||
* `clr`: a special library that unloads all definitions | ||
* `default`: mainline Orca language, loaded at startup (complete) | ||
* `orca157`: Orca [before the BFL breaking change](https://github.com/hundredrabbits/Orca/commit/4fd9ad72aafbb3f0c71139fd36ae421f1d8f352a) (complete) | ||
* `base`: not a very useful library by itself, defines the basics such as comments and numbers | ||
* `sb*`: Sborca collection of alternative operators (see `sborca.md`) | ||
|
||
## Usage examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
`use strict` | ||
|
||
/* global Operator */ | ||
/* global library */ | ||
|
||
library.base = {} | ||
|
||
library.base['#'] = function OperatorComment (orca, x, y, passive) { | ||
Operator.call(this, orca, x, y, '#', true) | ||
|
||
this.name = 'comment' | ||
this.info = 'Halts line' | ||
this.draw = false | ||
|
||
this.operation = function () { | ||
for (let x = this.x + 1; x <= orca.w; x++) { | ||
orca.lock(x, this.y) | ||
if (orca.glyphAt(x, this.y) === this.glyph) { break } | ||
} | ||
orca.lock(this.x, this.y) | ||
} | ||
} | ||
|
||
for (let i = 0; i <= 9; i++) { | ||
library.base[`${i}`] = function OperatorNull (orca, x, y, passive) { | ||
Operator.call(this, orca, x, y, '.', false) | ||
|
||
this.name = 'null' | ||
this.info = 'empty' | ||
|
||
// Overwrite run, to disable draw. | ||
this.run = function (force = false) { | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Editor ate trailing spaces, sorry.