saviola777 / haxball-headless-manager

Suite of management scripts for headless haxball hosts, including plugins with dependency management
MIT License
7 stars 3 forks source link

Add support for accessing HBInit through window object #34

Closed flying-aces-hb closed 3 years ago

flying-aces-hb commented 3 years ago

Some room script use window.HBInit to access the HBInit function, this is currently not supported for HHM plugins or room scripts, but support should be simple to add.

A first idea would be to create a shallow copy of the window object and inject our HBInit function, and then pass this window object as a parameter to the function in the context of which the plugins are executed.

Not sure if this works though (can we shadow the window object?) or if there are any problematic side effects.

saviola777 commented 3 years ago

A quick test showed that shadowing the window object works inside a function context.

saviola777 commented 3 years ago

This is now implemented.