summaryrefslogtreecommitdiff
path: root/Source/Samples/LuaxTest/script.lua
blob: 97890c00dd6dfe89c0b33e312d1df53540ebda50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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.Ctor = function(self, age, name, boy)
        self.age = age 
        self.name = boy:GetName()
        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.boy:GetAge())
end
function err(msg)
	print(msg)
end
xpcall(main, err)


-- end script
)scriptcode";