Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.
This repository was archived by the owner on May 8, 2024. It is now read-only.

Modding #11

@dinhero21

Description

@dinhero21

Modding (modifying) the game is currently possible using the dynamic plugin system. Simply use Reflection to inject your custom code into the game.

There are some limitations, for example, it is impossible to override module functions.
(warning: pseudo-code below)

// module

export function test () {
  return 'a'
}
// plugin/custom

import { test } from 'module'

// This will just rename test
test = () => 'b'

// Also won't work
Object.assign(test, () => 'b')

// Event after completely destroying test...
Object.setPrototypeOf(test, null)
for (const k of Object.getOwnPropertyNames(test)) {
  test[k] = undefined
  delete test[k]
}

// And ensuring its completely destroyed...
Object.getPrototypeOf(test)      // null
Object.getOwnPropertyNames(test) // ['arguments', 'caller', 'prototype']
test.arguments // null
test.caller    // null
test.prototype // undefined

// It still works...
test() // 'a'

The DX is also not great since all your code needs to be files inside the src[/public]/plugin (for ease of sharing and avoiding conflicts).

You also can not modify any non-code files without doing Reflection on the loaders themselves or using the node:fs module.

All that makes for a horrible, horrendous, impractical way of doing anything even slightly complex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions