Skip to content

Pass previous args to autocomplete source function#81

Open
TranquilMarmot wants to merge 1 commit intolimbonaut:masterfrom
TranquilMarmot:pass_args
Open

Pass previous args to autocomplete source function#81
TranquilMarmot wants to merge 1 commit intolimbonaut:masterfrom
TranquilMarmot:pass_args

Conversation

@TranquilMarmot
Copy link
Contributor

This lets you do progressive autocomplete based on previous args

Copy link
Owner

@limbonaut limbonaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature idea. The arg count is a bit fragile - I would add a check at registration.

)
LimboConsole.add_argument_autocomplete_source(
"spawn",
0,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registers autocomplete callback for index 0 for the second time. Should this be 1 instead?

Comment on lines +388 to +396
if arg_count == 0:
# No args, call as-is
argument_values = p_source.call()
else:
# Pass in dummy args
var test_args: PackedStringArray = []
test_args.resize(p_argument)
test_args.fill("")
argument_values = p_source.callv(test_args)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, the argument count for autocomplete callback needs to be either 0 or p_arguments. Should we have a check for arg_count == p_argument at registration?

if category == "enemy":
return ["minion", "boss"]
if category == "weapon":
return ["sword", "wand"]
Copy link
Owner

@limbonaut limbonaut Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sample code didn't work for me - need to add an else-branch (or fallback return [] at the bottom), or the callback with fail to register.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants