- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.lua
More file actions
Latest commit
24 lines (20 loc) · 523 Bytes
/
Copy pathtable.lua
File metadata and controls
24 lines (20 loc) · 523 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Character= {
New=function(_name, _hp, _power)
-- テーブルをreturnで返す
return {
name=_name,
hp=_hp,
power=_power,
Draw=function(_this)
print(_this.name, _this.hp, _this.power)
end
}
end
}
player=Character.New("player", 100, 10)
enemy=Character.New("enemy", 50, 5)
player.Draw(player)
-- シンタックスシュガー
-- テーブルに登録した関数を呼び出すときに『:』を使うと、
-- テーブル自体を第1引数に渡す事が出来る
enemy:Draw()