I am making a plugin that is going to be working with script. I need to be able to differentiate from elseif and if. I am searching for a substring that may start with elseif or if and depending on which I need to do an action. I am using find to search for the term but it identifies the if in the elseif which I don't want it to do.

Is there a way for me to identify the if by itself? Or do I need to add an additional check for this?

This is the section of code I am using:

while foundStartingValue == nil and counter < 50 do
	counter = counter + 5
	getContent2 = secondSourceFile:sub(findWhereActionStarts2-counter,  findWhereActionStarts2+30)
	foundStartingValue = getContent2:find("elseif") or getContent2:find("if") 
end

print(selectionName)
print(getContent2)

1 comment

0

Finally found something that worked, just added the %s before the if and now there needs to be some kind of space before it. FYI just leaving a space before it (" if") does not work.