fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
a8034e9
v2.1.5
1require ( "extensions.table" ) 2 3local class =require ( "class" ) 4local object =require ( "class.object" ) 5 6io . stdout : setvbuf ( "no" ) 7 8local ENTITY =class . create ( "Entity" ) 9 10ENTITY : ACCESSOR ( "Enabled" , "m_bEnabled" , false ) 11 12function ENTITY : Entity () 13( "3 - Entity Constructor" ) 14end 15 16function ENTITY : Bar () 17( "Hello world :)" , self ) 18end 19 20 21local ANIMAL =class . create ( "Animal" , "Entity" ) 22 23function ANIMAL : Animal () 24( "2 - Animal Constructor" ) 25self : super () 26end 27 28function ANIMAL : DoThing () 29( "6" ) 30end 31 32function ANIMAL : Think () 33( "5" , self ) 34self : DoThing () -- self will always be within the current class structure, so we go to line 26 and not line 48 35end 36 37 38local DOG =class . create ( "Dog" , "Animal" ) 39 40function DOG : Dog () 41( "1 - Dog Constructor" ) 42self : super () 43end 44 45function DOG : Think () 46( "4" ) 47self : super ( "Think" ) 48end 49 50function DOG : DoThing () 51( "7" ) 52self : super ( "DoThing" ) 53end 54 55local obj =object . new ( "Dog" ) 56( "BEGINNING TEST" , obj ) 57obj : Bar () 58obj : Think () 59 60-- This creates an override at the object level, the class method will remain in tact 61obj . Think =function ( this ) 62( "OVERRIDE" ) 63end 64 65obj : Think () 66 67-- Origial method can still be accessed via the class 68obj . class . Think ( obj ) 69 70( obj : getClass ()) 71( obj : getBaseClass ()) 72( obj : instanceof ( "Entity" )) 73( obj : instanceof ( "Animal" )) 74( obj : instanceof ( "Dog" )) 75 76( obj : IsEnabled ())