Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(addCommand): longString #597

Merged
merged 6 commits into from
Jul 1, 2024
Merged

feat(addCommand): longString #597

merged 6 commits into from
Jul 1, 2024

Conversation

BerkieBb
Copy link
Contributor

Whenever you have a command that has a text type at the end where you want to catch all text from that argument and on, only the first word will be assigned to that argument and the rest ends up all in an array which makes for a mixed table. With longString it catches those extras if the argument is at the end of the given params.

For example
/test test1 test2

Before only test1 would be shown.
After, all text will be shown.

I haven't tested this yet but ChatGPT said it will work fine

Comment on lines 48 to 56
elseif param.type == 'longString' and i == paramsNum then
value = arg

local argsNum = #args
if paramsNum < argsNum then
for a = i + 1, argsNum do
value = value .. ' ' .. args[a]
end
end
Copy link
Member

@thelindat thelindat Jun 26, 2024

Choose a reason for hiding this comment

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

Rather than concatenating the rest of the passed arguments, just take the raw string and trim off the other arguments. Same for the ts version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah I forgot we had a raw string

@BerkieBb
Copy link
Contributor Author

Raw string now used

@thelindat
Copy link
Member

To clarify, there's no need to split the string into many parts and concatenate or join strings together. Just get the position of the last argument in the raw string and then make a substring from that point.

@BerkieBb
Copy link
Contributor Author

Changed

@thelindat thelindat merged commit 64615a6 into overextended:master Jul 1, 2024
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