string gfind?

Place to get help with not working mods / modding interface.
Post Reply
Mernom
Fast Inserter
Fast Inserter
Posts: 122
Joined: Sun Jul 15, 2018 10:05 pm
Contact:

string gfind?

Post by Mernom »

Does the factorio lua lib contain that function? I can't call it during data.

Qon
Smart Inserter
Smart Inserter
Posts: 2091
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: string gfind?

Post 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

Mernom
Fast Inserter
Fast Inserter
Posts: 122
Joined: Sun Jul 15, 2018 10:05 pm
Contact:

Re: string gfind?

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: string gfind?

Post by eradicator »

Do you mean string.gmatch? Factorio only offers native lua functions, there is no special "string library" included.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”