@rbxts/centurion-ui 2.0.0-rc.2 → 2.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/app/init.luau +15 -8
package/package.json
CHANGED
package/src/app/init.luau
CHANGED
|
@@ -315,9 +315,11 @@ local function app()
|
|
|
315
315
|
end)
|
|
316
316
|
|
|
317
317
|
local function submit(value: string)
|
|
318
|
+
local trimmed = value:gsub("^%s*(.-)%s*$", "%1")
|
|
319
|
+
|
|
318
320
|
-- resolve from the submitted text rather than the analysis, which only
|
|
319
321
|
-- carries arguments when the cursor happens to sit on one
|
|
320
|
-
local submitted = centurion.resolve_command(
|
|
322
|
+
local submitted = centurion.resolve_command(trimmed)
|
|
321
323
|
raw_text("")
|
|
322
324
|
analysis(default_analysis)
|
|
323
325
|
|
|
@@ -334,11 +336,16 @@ local function app()
|
|
|
334
336
|
end
|
|
335
337
|
|
|
336
338
|
cmd_history_index = 0
|
|
337
|
-
|
|
339
|
+
|
|
340
|
+
local history_index = table.find(cmd_history, trimmed)
|
|
341
|
+
if history_index ~= nil then
|
|
342
|
+
table.remove(cmd_history, history_index)
|
|
343
|
+
end
|
|
344
|
+
table.insert(cmd_history, 1, trimmed)
|
|
338
345
|
|
|
339
346
|
local cmd = submitted.name
|
|
340
347
|
if not cmd then
|
|
341
|
-
log(
|
|
348
|
+
log(trimmed, {
|
|
342
349
|
success = false,
|
|
343
350
|
message = "Unknown command",
|
|
344
351
|
timestamp = os.time(),
|
|
@@ -350,12 +357,12 @@ local function app()
|
|
|
350
357
|
executing(executing() + 1)
|
|
351
358
|
|
|
352
359
|
-- pass the submitted text so that ctx.input keeps its original quoting
|
|
353
|
-
local ok, result = pcall(centurion.execute_command, Players.LocalPlayer, cmd, submitted.args,
|
|
360
|
+
local ok, result = pcall(centurion.execute_command, Players.LocalPlayer, cmd, submitted.args, trimmed)
|
|
354
361
|
executing(executing() - 1)
|
|
355
362
|
|
|
356
363
|
if not ok then
|
|
357
|
-
warn(`Failed to execute '{
|
|
358
|
-
log(
|
|
364
|
+
warn(`Failed to execute '{trimmed}': {result}`)
|
|
365
|
+
log(trimmed, {
|
|
359
366
|
success = false,
|
|
360
367
|
message = "Failed to execute command",
|
|
361
368
|
timestamp = os.time(),
|
|
@@ -365,10 +372,10 @@ local function app()
|
|
|
365
372
|
|
|
366
373
|
if result.response then
|
|
367
374
|
if result.response.message ~= "" then
|
|
368
|
-
log(
|
|
375
|
+
log(trimmed, result.response)
|
|
369
376
|
end
|
|
370
377
|
else
|
|
371
|
-
log(
|
|
378
|
+
log(trimmed, {
|
|
372
379
|
success = true,
|
|
373
380
|
message = "Command executed",
|
|
374
381
|
timestamp = os.time(),
|