Variables in functions

Place to get help with not working mods / modding interface.
Post Reply
User avatar
sporefreak
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Apr 17, 2016 12:55 am
Contact:

Variables in functions

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

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Variables in functions

Post by prg »

You're looking for string concatenation?

Code: Select all

icon = "__More-Subgroups__/graphics/item-group/"..(Bgreens and "image1" or "image2")..".png"
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

User avatar
sporefreak
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Apr 17, 2016 12:55 am
Contact:

Re: Variables in functions

Post 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

Post Reply

Return to “Modding help”