summaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-18 16:26:00 +0500
committerilotterytea <iltsu@alright.party>2025-04-18 16:26:00 +0500
commit1acbe54c335da85c965ed5acace92a5f20856666 (patch)
tree78f775c2c91c991dcee0fb88e16cd955b3f1008b /bot
parent9b1a11e8fee33abb933aa3836faf60cc14deb68d (diff)
fix: return table in str_split
Diffstat (limited to 'bot')
-rw-r--r--bot/src/commands/lua.cpp15
1 files changed, 11 insertions, 4 deletions
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<sol::state> 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<std::string> 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) {