Multi file problem

Place to get help with not working mods / modding interface.
Post Reply
yagaodirac
Fast Inserter
Fast Inserter
Posts: 152
Joined: Sun Jun 16, 2019 4:04 pm
Contact:

Multi file problem

Post by yagaodirac »

1, Is it possible to access functions or variables in another file? Through require directive or something else?
2, Any method to iterate all the custom variables and functions in a scenerio?
3, How to restart mtn fortress with console, without deleting the data.??? file in save file?

Or link to the answers directly.

Thanks.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1645
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Multi file problem

Post by Pi-C »

yagaodirac wrote:
Sun Jun 28, 2020 2:30 pm
1, Is it possible to access functions or variables in another file? Through require directive or something else?
In this mod, I've stored different functions and variable definitions in an extra file (common.lua):

Code: Select all

return function ()
    local common = {}

    ------------------------------------------------------------------------------------
    -- Read startup settings
    common.get_startup_settings= function()
        local f_name = "common.get_startup_settings()"

        if settings and settings.startup then
            common.long_reach = settings.startup["GCKI-long_reach"].value
            common.debug_in_log = settings.startup["GCKI-debug_in_log"].value
        else
            common.error("Startup settings are not available!", f_name)
        end
    end
[…]
    return common
end
I can then access these functions/variables from other files:

Code: Select all

GCKI = require('common')
[…]

GCKI.get_startup_settings()
[…]
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Post Reply

Return to “Modding help”