/// <summary> /// Pushes the value on to the lua stack based on value.GetType(), and how that type maps to a lua type. /// Pushes nil if object is null or typeof object is not a basic type /// </summary> /// <param name="value">the value to push on to the stack</param> public void PushBasicValue(object value) { //push value on the stack if (value == null) { Lua.lua_pushnil(L); return; } if (value.GetType() == typeof(string)) { Lua.lua_pushstring(L, value.ToString()); return; } if (value.GetType() == typeof(bool)) { Lua.lua_pushboolean(L, (bool)value); return; } if (value.GetType() == typeof(decimal)) { Lua.lua_pushnumber(L, Convert.ToDouble(((decimal)value))); return; } if (value.GetType() == typeof(float)) { Lua.lua_pushnumber(L, Convert.ToDouble(((float)value))); return; } if (value.GetType() == typeof(double)) { Lua.lua_pushnumber(L, Convert.ToDouble(((double)value))); return; } if (value.GetType() == typeof(int)) { Lua.lua_pushinteger(L, (int)value); return; } if (value.GetType() == typeof(DateTime)) { Lua.lua_pushstring(L, ((DateTime)value).ToString()); return; } if (value.GetType() == typeof(Guid)) { Lua.lua_pushstring(L, ((Guid)value).ToString()); return; } if (value.GetType().IsEnum) { Lua.lua_pushstring(L, value.ToString()); return; } Lua.lua_pushnil(L); }