-
Notifications
You must be signed in to change notification settings - Fork 772
Added countnameditem script command. #2307
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
Conversation
251c577 to
a6beb23
Compare
|
could we have extra parameters for count named item of other specific char id that exists in player inventory too? use-case may not be wide, but seem useful if we could have it to count item that named using other player name in different player inventory. |
Sure. I'll need to tweak the code a bit but should be possible. |
|
Hmmm might be a bit more complex than I previously thought. So... even in the current state, the inscribed character has to be online for the count to be successful. I'm not seeing any existing methods in script.c that allows the look up of offline character data. Should we possibly add a new function within pc.c that allows searching for a character's basic information even if they're offline? Or possibly a direct sql command within script.c on the function for countnameditem? Essentially we'd need to look up a character by either their name or id and use their char id within the slot 3 and 4 checks. The other option is leaving it as self-named items only, which is how the aegis command works. |
a6beb23 to
990d2ca
Compare
doc/script_commands.txt
Outdated
| } | ||
| next; | ||
| mes("[Item Checker]"); | ||
| mes("You have "+countnameditem(Apple, "John")+" apples with John's name on it!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want support for translations, you cant split sentenses.
Need use sprintf or other formatting functions.
Example: mes(sprintf(_$("You have %d apples with John's name on it!"), countnameditem(Apple, "John"))
But this is docs, because this i not sure is it really need here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or
| mes("You have "+countnameditem(Apple, "John")+" apples with John's name on it!"); | |
| mesf("You have %d apples with John's name on it!", countnameditem(Apple, "John")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that docs should show the recommended code style, since this is where people learn/copy from. The suggested mesf() variant is the cleanest/most appropriate
doc/script_commands.txt
Outdated
| } | ||
| next; | ||
| mes("[Item Checker]"); | ||
| mes("You have "+countnameditem(Apple, "John")+" apples with John's name on it!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that docs should show the recommended code style, since this is where people learn/copy from. The suggested mesf() variant is the cleanest/most appropriate
Signed-off-by: Haru <[email protected]>
990d2ca to
9d58203
Compare
Pull Request Prelude
Changes Proposed
Adds a script command to return the number of signed items a character has in their inventory.
Currently you have to do the following for this same functionality:
This pull request changes that so you can simply do this: