string script = R"scriptcode( -- start script function main() local a = 19 print(Asura.version) print(Asura.author.name) print("ok") print(Asura.author.func()) -- local boy = Asura.SimBoy.New("I am peter!", 19) -- boy:Say() -- print(Asura.SimSchool.GetName()) print(Asura.SimBoy.Class) print(Asura.SimBoy.Gender) print(Asura.SimBoy.GetClassName()) print(Asura.School.GetName()) print(Asura.School.Region) --[[ local Kid = Asura.SimBoy.Extend() Asura.Kid = Kid Kid.New = function(self, height, age) self.base(age) self.height = height end Kid.GetHeight = function(self) print(self.height) end local kid = Kid.New(110, 12) kid:GetHeight() ]] local kid = Asura.SimBoy.New(23, "Chai") print(kid:GetAge()) print(kid:GetName()) kid.fruit = function() return "apple" end print(kid.fruit()) print(Asura.SimBoy.GetGender()) Asura.SimBoy.Havefun = function() return "Boys have some fun!" end print(Asura.SimBoy.Havefun()) -- ÐÞ¸ÄÀà·½·¨ Asura.SimBoy.Foo = function() return "SimBoy.Foo" end print(Asura.SimBoy.Foo()) print(Asura.EGender.BOY) --Asura.EGender.BOY = 2 print(Asura.EGender.BOY) print(Asura.SimBoy.EHabits.Girls) print(Asura.EHabits.Girls) print(kid) kid:Write(function() return "kid:Write()" end ) print(kid:Speak()) kid:Write(function() return "kid:Write() 2" end ) print(kid:Speak()) ------------------- plain class test local Foo = Asura.Class("Foo") Foo.__init = function(self, age, name, boy) self.age = age self.name = name self.boy = boy end Foo.GetAge = function(self) return self.age end Foo.GetName = function(self) return self.name end local foo = Foo.New(10, "lee", kid) print(foo:GetName()) print(Foo.GetClassName()) print(foo.GetClassName()) print(foo.boy:GetAge()) --------------------inherits test local Coo = Foo.Extend("Coo") print(Coo.GetClassName()) local coo = Coo.New(20, "Wang", kid) print(coo:GetAge()) Coo.__init = function(self, age, name, boy) self.age = age - 1 self.name = boy:GetName() self.boy = boy self.__base.__init(self, age, "Wangba", boy) end Coo.GetName = function(self) local name = self.__base.GetName(self) return "his name is " .. name end local coo2 = Coo.New(20, "Wang", kid) print(coo2:GetAge()) print(coo2.GetClassName()) print(coo2:GetName()) print(coo2) print(coo) print(coo2:TypeOf("Foo")) ---------------------plain enum test local ERace = Asura.Enum("ERace", { ["White"] = 1, ["Asian"] = 2, ["Black"] = 3, }) print(ERace.White) print(ERace.Asian) ----------------------native class inherit test -- local Boy2 = Asura.SimBoy.Extend("Boy2") -- Boy2.Speak = function(self) -- return self.__base.GetAge(self) -- end -- Boy2.__init = function(self, age, name) -- print("__init " .. age) -- print("__init " .. name) -- end -- local boy22 = Boy2.New(12, "Liu") -- print(boy22) -- print(boy22:Speak()) ------------------------gc test local boy = Asura.SimBoy.New(11, "chaichai") boy = nil io.read() end function err(msg) print(msg) end xpcall(main, err) -- end script )scriptcode";