From 1acbe54c335da85c965ed5acace92a5f20856666 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Fri, 18 Apr 2025 16:26:00 +0500 Subject: fix: return table in str_split --- bot/src/commands/lua.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp index 337551f..90b734e 100644 --- a/bot/src/commands/lua.cpp +++ b/bot/src/commands/lua.cpp @@ -377,10 +377,17 @@ namespace bot::command::lua { } void add_string_library(std::shared_ptr state) { - state->set_function("str_split", - [](const std::string &text, const char &delimiter) { - return utils::string::split_text(text, delimiter); - }); + state->set_function( + "str_split", [state](const std::string &text, const char &delimiter) { + sol::table o = state->create_table(); + std::vector parts = + utils::string::split_text(text, delimiter); + + std::for_each(parts.begin(), parts.end(), + [&o](const std::string &part) { o.add(part); }); + + return o; + }); state->set_function( "str_to_feature", [state](const std::string &feature) { -- cgit v1.2.3