OgarII
OgarII copied to clipboard
plugins [high priority]
(I recommend you to fs.readdir a folder to get all .js files, then require them (they should export a class)|provide a function for adding plugin classes), in this class there will be a constructor defining this.info (or super()) like plugin name, version, author, api version etc. and in the class they'll define specified function like onPacketRecieve(player, packet) { code.. }, your system will check if this function exists in the plugins class (so that people will not have to define every single function) then call it like class.onPacketRecieve(player, packet);
A plugin system would be nice, here are some..
Suggested events/functions:
- [ ] onPacketRecieve(player, packet)
- [ ] onPlayerSplit(player, oldCellAmount, newCellAmount)
- [ ] onPlayerChat(player, message)
- [ ] onPlayerJoin(player, ip)
- [ ] onPlayerLeave(player, ip)
- [ ] onPlayerSpawn(player)
- [ ] onPlayerDie(player)
- [ ] onPlayerEjectMass(player, ejectedCell)
- [ ] onMothercellEjectMass(mothercell, ejectedCell)
- [ ] onVirusSplit(mainVirus, newVirus)
- [ ] something.setOption(option: for example merge delay, speed, mass etc.)
- [ ] something.getOption(option: ^)
- [ ] something.getInfo(info: ip, id, size, mass, color, cells etc.)
- [ ] something.setInfo(info: ^)
- [ ] something.remove() // kill a player, remove a cell/virus
- [ ] player.split()
- [ ] player.merge()
- [ ] player.connection // websocket client
- [ ] player.request // websocket upgrade request
access for writer.js and reader.js should be given
Already a thing, it’s called a Mode. Modes don’t support all of the above events, but it’s relatively easy to add them.
plugins [high priority]
[high priority]
[high priority]
[high priority]
1 year soon:tm: