Created
May 14, 2017 07:17
-
-
Save z3t0/16aa90a2a872bddb116ec7341676c446 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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