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

Fix durability Regex for tooltip parsing #25

Merged
merged 1 commit into from
Jan 19, 2025
Merged

Conversation

drcrazy
Copy link
Contributor

@drcrazy drcrazy commented Jan 14, 2025

string.gsub has two return values: processed string and amount of substitutions made.

This result in a table returned to PawnRegexes:

[1]="^Durability: %d+ / %d+$",
[2]=2

Thus PawnLookForSingleStat will treat it as a Stat:

https://github.com/VgerMods/Pawn/blob/bb341eeebe9a8ebeb0499554766b6a7a9984271f/Pawn.lua#L2540C1-L2544C37

@TravisSpomer
Copy link
Member

I hate Lua so much.

@TravisSpomer TravisSpomer merged commit 40070f3 into VgerMods:main Jan 19, 2025
@TravisSpomer
Copy link
Member

Thanks. I'm probably going to rewrite this and the other functions around there with select(1, gsub(...)) just to avoid any impossible-to-find nightmare bugs in the future.

@TravisSpomer
Copy link
Member

Turns out I can just use parentheses to drop the other return values.

function PawnGameConstantIgnoredNumberPlaceholder(Text)
	return (gsub(PawnGameConstant(Text), "%%%%d", "%%d+"))
end

This change will be in Pawn 2.10.9 when that's released.

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