MetaField pushes onto the stack the field event from the metatable of the object at index. If the object does not have a metatable, or if the metatable does not have this field, returns false and pushes nothing.
(l *State, index int, event string)
| 80 | // object at index. If the object does not have a metatable, or if the |
| 81 | // metatable does not have this field, returns false and pushes nothing. |
| 82 | func MetaField(l *State, index int, event string) bool { |
| 83 | if !l.MetaTable(index) { |
| 84 | return false |
| 85 | } |
| 86 | l.PushString(event) |
| 87 | l.RawGet(-2) |
| 88 | if l.IsNil(-1) { |
| 89 | l.Pop(2) // remove metatable and metafield |
| 90 | return false |
| 91 | } |
| 92 | l.Remove(-2) // remove only metatable |
| 93 | return true |
| 94 | } |
| 95 | |
| 96 | // CallMeta calls a metamethod. |
| 97 | // |