Skip to content

Instantly share code, notes, and snippets.

@z3t0
Created May 14, 2017 07:17
Show Gist options
  • Save z3t0/16aa90a2a872bddb116ec7341676c446 to your computer and use it in GitHub Desktop.
Save z3t0/16aa90a2a872bddb116ec7341676c446 to your computer and use it in GitHub Desktop.
class modLoader {
constructor (game) {
this.game = game
this.mods = []
}
registerMod (mod) {
this.mods.push(mod)
mod.init(this.game)
}
enableMod (name) {
let mod = findMod(name)
// how do i error handle when a mod is not found?
if (mod != undefined)
mod.enableMod()
}
findMod (name) {
for (var i = 0; i < this.mods.length; i++) {
if (this.mods[i].name == name)
return this.mods[i]
}
return undefined
}
}
module.exports = modLoader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment