diff --git a/src/module/globalfuns.cpp b/src/module/globalfuns.cpp index 40a8bb4..ef234a5 100644 --- a/src/module/globalfuns.cpp +++ b/src/module/globalfuns.cpp @@ -59,18 +59,18 @@ void module::globalfuncs::create_env(const std::string& lua_filepath,sol::this_s t.detach(); } -std::optional module::globalfuncs::toint(const sol::object& obj) +std::optional module::globalfuncs::toint(const sol::object& obj) { sol::type t = obj.get_type(); switch (t) { case sol::type::number: // 直接将数字转换为 int - return obj.as(); + return obj.as(); case sol::type::string: { // 尝试将字符串转换为 int std::string s = obj.as(); try { - return std::stoi(s); + return std::stoll(s); } catch (const std::exception&) { return std::nullopt; diff --git a/src/module/globalfuns.h b/src/module/globalfuns.h index 186dc7a..a207a82 100644 --- a/src/module/globalfuns.h +++ b/src/module/globalfuns.h @@ -57,7 +57,7 @@ namespace module /// 转INT /// /// - static std::optional toint(const sol::object& arg); + static std::optional toint(const sol::object& arg); static void regist(sol::state* lua);