- Fix script error due to bad change of default
| Downloads | 133,913 |
|---|---|
| Updated | 10 months ago |
| Released | 4 years ago |
| Numeric ID | 252 |
| Min. Openplanet | 1.27.9 |
You may need to install this plugin as a dependency for another plugin that you want to use. In that case, you can install and forget -- it'll operate silently the background. That's all you need to know, but read on if you're curious.
MLHook is a dependency plugin (for use by other plugins) to enable running code at the same time as Manialink does. It is also a developer tool used to inspect all Custom Events. (You must have the developer signature mode enabled.)
As a dependency, MLHook lets plugins interact with game elements that would not otherwise be possible, and send Custom Events that would otherwise not be possible.
Please report performance issues! See "About" for who/where.
Current Features:
CGameManialinkScriptHandler.SendCustomEvent (e.g., to display a ghost) or the playground's SendCustomEvent function.declare (netread) [Type] [Name] for [GameObject] and pass back to AngelScriptMLHook::HookMLEventsByType base class. (see src/Exports/ExportShared.as)MLHook::Queue_MessageManialinkPlayground(PageUID, {"Command_Blah", "Arg_Foo"}) (see src/ExportCode.as via src/Exports/Export.as)(Note: additionally, see the section at the bottom)
Suggestions/feedback requested!
This plugin is only possible due to many prior efforts and a lot of trial and error. This is a non-exhaustive list of those who are owed partial credit and appreciation:
License: Public Domain
Authors: XertroV
Suggestions/feedback: @XertroV on Openplanet discord
Code/issues: https://github.com/XertroV/tm-ml-to-angelscript-hook
GL HF
MLHook currently allows 2-way comms between AS and ML.
Also, the use of SendCustomEvent on script handlers without crashing the game.
In general, sending custom events seems to be fine when .Page is not null -- which it always is during the typical times that AngelScript runs.
As far as I can tell, .Page is only not-null when Manialink code is executing, and even then, not all of the time.
For a detailed example of how to use MLHook, see MLFeed: Race Data.
Examples of direct usage (ctrl+f for 'MLHook'):
.Script.txt file -- The prior examples handle this case and encode the script as a string rather than reading it as a file.)Add this to your info.toml:
[script]
dependencies = [ 'MLHook' ]
Send CGameManialinkScriptHandler Custom Events via:
void MLHook::Queue_SH_SendCustomEvent(const string &in type, string[] &in data = {})
void MLHook::Queue_PG_SendCustomEvent(const string &in type, string[] &in data = {})
Inject Manialink code to react to msgs from MLHook (which are independent of TM's script events).
void MLHook::InjectManialinkToPlayground(const string &in PageUID, const string &in ManialinkPage, bool replace = false)
void MLHook::Queue_MessageManialinkPlayground(const string &in PageUID, const string &in msg)
void MLHook::RemoveInjectedMLFromPlayground(const string &in PageUID)
To run code whenever an event with a particular type is detected:
void MLHook::RegisterMLHook(HookMLEventsByType@ hookObj, const string &in type = "")
void MLHook::UnregisterMLHookFromAll(HookMLEventsByType@ hookObj)
To safely unload injected ML and hooks when your plugin is unloaded, add this to Main.as (or wherever):
void OnDestroyed() { _Unload(); }
void OnDisabled() { _Unload(); }
void _Unload() {
trace('_Unload, unloading all hooks and removing all injected ML');
MLHook::UnregisterMLHooksAndRemoveInjectedML();
}
Example using injected ML to refresh records: https://github.com/XertroV/tm-somewhat-better-records/blob/master/src/Main.as
You'll probably to recover from compile/syntax error:
While developing, the manialink linter is very very useful to avoid wasting time waiting for recovery restart b/c you left out a ; or something.
Fix crash while changing maps