Use external libraries

Place to get help with not working mods / modding interface.
Post Reply
Hermios
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat Aug 13, 2016 2:57 pm
Contact:

Use external libraries

Post by Hermios »

Hi
I assume this is a basic question, but I couldn't find the info anywhere:
How can I handle external libs, on the same concept than bob's mods. Indeed, the bob's library is required for all the other mods. But I couldn't find how he refers to it.
Any help?
Many thanks

Niko

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Use external libraries

Post by DaveMcW »

Every variable and function used in the data.lua stage is global, unless it is explicitly declared as local. This means you can use variables and functions defined in another mod with no extra effort.

Add the library mod as a dependency in info.json to make sure it loads first.

Control.lua enforces a sandbox around mods, you can only share data by using LuaRemote.

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

Re: Use external libraries

Post by eradicator »

Dependencies are defined in info.json as "[? optional marker, (?) hidden optional marker or ! incompatibility marker] mod-name [comparator, version]".

Code: Select all

  "dependencies"    : [
    "base >= 0.16.25",
    "mandatory-mod-name",
    "? optional-mod-name > 1.2.3"
    ]
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.

Hermios
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat Aug 13, 2016 2:57 pm
Contact:

Re: Use external libraries

Post by Hermios »

Great, many thanks for the answers, especially data.lua!
I'll implement it in the next version of my mods

Niko

Post Reply

Return to “Modding help”