Page 1 of 1

Variables in functions

Posted: Tue Jun 28, 2016 7:07 pm
by sporefreak
Im having a bit of trouble understanding how to call Variables in functions, I want to change the image of a crafting menu tab based on what mods are installed, (Using preset images)
So i want something like,
code
Or perhaps there is a way to call an image replace if said mod is installed? (i might look at happy factorio to learn how to do that instead) Which would be better?
Any google searches i tried didnt turn up anything besides explaining how functions work, and i could just be blind but i didnt see anything about calling variables in the way im wanting to.
(im coming into Lua from Javascript so if these are not functions please correct me :P as well as anything else i have messed up besides my life)

Re: Variables in functions

Posted: Tue Jun 28, 2016 7:14 pm
by prg
You're looking for string concatenation?

Code: Select all

icon = "__More-Subgroups__/graphics/item-group/"..(Bgreens and "image1" or "image2")..".png"

Re: Variables in functions

Posted: Tue Jun 28, 2016 8:41 pm
by sporefreak
prg wrote:You're looking for string concatenation?

Code: Select all

icon = "__More-Subgroups__/graphics/item-group/"..(Bgreens and "image1" or "image2")..".png"
I have no idea what im looking for apparently but that may be it, ill look into it as soon as I can. Thanks a ton