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(module/shops): check for the latest occurrence of space #1236

Merged
merged 2 commits into from
Apr 2, 2023

Conversation

mahanmoulaei
Copy link
Contributor

@mahanmoulaei mahanmoulaei commented Apr 1, 2023

This fixes the error that is thrown in case playerInv.open has more than 1 space occurrence in its string value.
Previously, when the playerInv.open value was something like "Cat Cafe Shop 1", the shopType would have been "Cat" instead of "Cat Cafe Shop".

Also tested it with global shops so no such #1146 issue would happen.

This fixes the error that is thrown in case `playerInv.open` has more than 1 space occurrence in its string value.

Previously, when the `playerInv.open` value was something like "Cat Cafe Shop 1", the `shopType` would have been "Cat" instead of "Cat Cafe Shop".
@thelindat
Copy link
Member

local function test(str, pattern)
	local shopType, shopId = str:match(pattern)
	print('~~~', str, pattern)
	print('type', shopType)
	print('id', shopId)
	print()
end

test("Cat Cafe Shop 1", "^(.-)%s+(%S+)$")
test("Cat Cafe Shop", "^(.-)%s+(%S+)$")
~~~	Cat Cafe Shop 1	^(.-)%s+(%S+)$
type	Cat Cafe Shop
id	1

~~~	Cat Cafe Shop	^(.-)%s+(%S+)$
type	Cat Cafe
id	Shop

Copy link
Member

@thelindat thelindat left a comment

Choose a reason for hiding this comment

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

Probably need to double-check other input.

modules/shops/server.lua Outdated Show resolved Hide resolved
@thelindat thelindat merged commit def54e4 into overextended:main Apr 2, 2023
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