Skip to content

Commit

Permalink
Further work
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteMasterEric committed Feb 22, 2022
1 parent cb59111 commit dfe4985
Show file tree
Hide file tree
Showing 20 changed files with 1,002 additions and 202 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Parse any scripted classes with `registerAllScriptClasses()`, get the list of scripted classes extending a given class with `listScriptClassesExtendingClass()`, then instantiate it with `createScriptClassInstance(className, args)`. You can cast the `AbstractScriptClass` to the appropriate type once instantiated.
- Note this interface is subject to change and may be deprecated in favor of a more seamless interface in the future.
### Removed
- The `POLYMOD_USE_HSCRIPTEX` flag has been made redundant. `hscript-ex` will be used if available, and `hscript` will be used otherwise.
- The `POLYMOD_USE_HSCRIPTEX` flag has been made redundant. A fork of `hscript-ex` is now bundled into Polymod.

## [1.4.3] - 2022-02-18
### Fixed
- OpenFLBackend no longer breaks when you are using the main version of OpenFL.
Expand Down
38 changes: 38 additions & 0 deletions docs/docs/scripted-classes.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Scripted Classes
---
{% include toc.html %}

# Scripted Classes

See the `openfl_hscript_class` sample for an example of this in action.

This documentation is a WIP because I only just got this working, but here's a quick and dirty rundown:

## Creating a Scripted Class

1. Create a class like this:

```
@:hscriptClass
class ScriptedStage extends Stage implements HScriptable {
}
```

## Abilities and Limitations of Scripted Classes

There are many things which you can do within a scripted class, including but not limited to:

* Override the constructor (using `public function new() { ... }`)
* Import modules and instantiate objects (like `import flixel.FlxG`).
* Access public or private fields of the superclass, including functions.

There are some things to watch out for though:

* You can't override `static` functions in a script.
* You can't override a function which uses a private class as an argument.
* This is not possible in any Haxe program so don't worry about this.
* You can't (CURRENTLY) override functions with an optional argument like `function create(?name:String = 'test')`
* You can't (CURRENTLY) override functions which utilize a constrained generic type like `function test<T:Iterable<String>>(a:T)`
* I think fully generic types work? Haven't tested.
* Sometimes using `this.xyz` to access fields doesn't work, but just `xyz` does.
2 changes: 1 addition & 1 deletion haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"tags": ["mod","game","data","asset"],
"description": "An atomic modding framework for Haxe games",
"version": "1.5.0",
"releasenote": "Minor bug fix to the OpenFL backend",
"releasenote": "Added a new framework to support scripted classes",
"contributors": ["MasterEric", "larsiusprime"],
"dependencies": {
"hscript-ex": "0.0.0"
Expand Down
Loading

0 comments on commit dfe4985

Please sign in to comment.