[script plugin] some more refactoring
[script plugin] Implemented the event managment in C instead of Lua