summaryrefslogtreecommitdiff
path: root/Source/Samples/LuaxTest/script.lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-17 11:41:14 +0800
committerchai <chaifix@163.com>2019-03-17 11:41:14 +0800
commit5a9bbd481f94119488d845f5b8272734dfda82cc (patch)
tree15a340153d6a32fcaeee840906685519aaa59a46 /Source/Samples/LuaxTest/script.lua
parentad2805aa839892589c13a615730da52f6e474709 (diff)
*enum
Diffstat (limited to 'Source/Samples/LuaxTest/script.lua')
-rw-r--r--Source/Samples/LuaxTest/script.lua28
1 files changed, 28 insertions, 0 deletions
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)