uyjulian Posted March 4, 2020 Share Posted March 4, 2020 (edited) It is possible to override a TJS2 class with the same name, but you must follow the following rules: 1. Use a unique identifier when declaring a class Example of this wrong usage: global.ClassToOverride_original = global.ClassToOverride; class ClassToOverride extends global.ClassToOverride_original { } When instantiating the class, this will cause a segmentation fault. 2. Do not use an identifier that has been deleted Example of this wrong usage: global.ClassToOverride_original = global.ClassToOverride; delete global.ClassToOverride; class ClassToOverride extends global.ClassToOverride_original { } This will cause Member does not exist exception. 3. Place the original class name as the constructor With these three rules, we can override a TJS2 class while keeping the same name. global.ClassToOverride_uniqueidentifier_original = ClassToOverride; class ClassToOverride_uniqueidentifier_override extends ClassToOverride_uniqueidentifier_original { function ClassToOverride_uniqueidentifier_override() { super.ClassToOverride(...); } function ClassToOverride() { ClassToOverride_uniqueidentifier_override(...); } } global.ClassToOverride = ClassToOverride_uniqueidentifier_override; This is a cleaner way of adding features like word wrapping or line breaking to KAG, compared to some code I've seen. Edited March 4, 2020 by uyjulian Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.