ToValue convertes the value at index into a generic Go interface{}. The value can be a userdata, a table, a thread, a function, or Go string, bool or float64 types. Otherwise, the function returns nil. Different objects will give different values. There is no way to convert the value back into it
(index int)
| 869 | // |
| 870 | // http://www.lua.org/manual/5.2/manual.html#lua_tovalue |
| 871 | func (l *State) ToValue(index int) interface{} { |
| 872 | v := l.indexToValue(index) |
| 873 | switch v := v.(type) { |
| 874 | case string, float64, bool, *table, *luaClosure, *goClosure, *goFunction, *State: |
| 875 | case *userData: |
| 876 | return v.data |
| 877 | default: |
| 878 | return nil |
| 879 | } |
| 880 | return v |
| 881 | } |
| 882 | |
| 883 | // PushString pushes a string onto the stack. |
| 884 | // |