Page 1 of 1

string gfind?

Posted: Tue Jul 13, 2021 12:16 pm
by Mernom
Does the factorio lua lib contain that function? I can't call it during data.

Re: string gfind?

Posted: Tue Jul 13, 2021 1:06 pm
by Qon
What do you mean when you say "I can't call it"? You didn't provide code. How do you call it? Do you call it correctly?

I've used gsub in data stage code (Capsule Ammo 0.1.5 data.lua L22). If gsub is available the gfind is as well.

Do you know when to use . and when to use : ? Was a while since I used Lua string library functions now but I imagine that this might trip you up.

Code: Select all

local s = "hello"
local result
result = s:gfind(arg0, arg1, arg2)
result = string.gfind(s, arg0, arg1, arg2)  -- alternative

Re: string gfind?

Posted: Fri Jul 16, 2021 3:49 pm
by Mernom
Removing the G allowed a call of string.find (). This looks to me like gfind is not included in the factorio string library pack.

Re: string gfind?

Posted: Fri Jul 16, 2021 5:23 pm
by eradicator
Do you mean string.gmatch? Factorio only offers native lua functions, there is no special "string library" included.