From 5a9bbd481f94119488d845f5b8272734dfda82cc Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 17 Mar 2019 11:41:14 +0800 Subject: *enum --- Source/Samples/LuaxTest/script.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Source/Samples') diff --git a/Source/Samples/LuaxTest/script.lua b/Source/Samples/LuaxTest/script.lua index 97890c0..7cea38d 100644 --- a/Source/Samples/LuaxTest/script.lua +++ b/Source/Samples/LuaxTest/script.lua @@ -80,7 +80,35 @@ function main() 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.Ctor = function(self, age, name, boy) + self.age = age - 1 + self.name = boy:GetName() + self.boy = boy + self.base.Ctor(self, age, name, 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()) +---------------------plain enum test + local ERace = Asura.Enum("ERace", { + ["White"] = 1, + ["Asian"] = 2, + ["Black"] = 3, + }) + print(ERace.White) + print(ERace.Asian) end function err(msg) print(msg) -- cgit v1.1-26-g67d0