[Z] Adventure


As you expand your base or simply explore the surface of Nauvis, you will find abandoned constructions left behind by someone else, among those will be storages with useful resources, deserted production lines, as well as whole complexes for mass production of various parts.

4 years ago
0.16 - 0.17
17

b errors every second

4 years ago

After quite a while playing a single-player game, this mod started to give regular alerts:
6920.578 Script @ZAdventure/control.lua:42: [[ZADV]]
ZADV_Base-exchange post.on_event[0] error:
ZAdventure/areas.lua:2034: attempt to call global 'switchGUI' (a nil value)

6920.745 Script @ZAdventure/control.lua:42: [[ZADV]]
ZADV_Base-exchange post.on_event[0] error:
ZAdventure/areas.lua:2034: attempt to call global 'switchGUI' (a nil value)

6921.745 Script @ZAdventure/control.lua:42: [[ZADV]]
ZADV_Base-exchange post.on_event[0] error:
ZAdventure/areas.lua:2034: attempt to call global 'switchGUI' (a nil value)

6921.912 Script @ZAdventure/control.lua:42: [[ZADV]]
ZADV_Base-exchange post.on_event[0] error:
ZAdventure/areas.lua:2034: attempt to call global 'switchGUI' (a nil value)

6922.913 Script @ZAdventure/control.lua:42: [[ZADV]]
ZADV_Base-exchange post.on_event[0] error:
ZAdventure/areas.lua:2034: attempt to call global 'switchGUI' (a nil value)

6923.080 Script @ZAdventure/control.lua:42: [[ZADV]]
ZADV_Base-exchange post.on_event[0] error:
ZAdventure/areas.lua:2034: attempt to call global 'switchGUI' (a nil value)

6924.080 Script @ZAdventure/control.lua:42: [[ZADV]]
ZADV_Base-exchange post.on_event[0] error:
ZAdventure/areas.lua:2034: attempt to call global 'switchGUI' (a nil value)

6924.248 Script @ZAdventure/control.lua:42: [[ZADV]]
ZADV_Base-exchange post.on_event[0] error:
ZAdventure/areas.lua:2034: attempt to call global 'switchGUI' (a nil value)

6925.248 Script @ZAdventure/control.lua:42: [[ZADV]]
ZADV_Base-exchange post.on_event[0] error:
ZAdventure/areas.lua:2034: attempt to call global 'switchGUI' (a nil value)

6925.416 Script @ZAdventure/control.lua:42: [[ZADV]]
ZADV_Base-exchange post.on_event[0] error:
ZAdventure/areas.lua:2034: attempt to call global 'switchGUI' (a nil value)

4 years ago

Just got spammed with that same error message -- on Factorio 0.17.60 and [Z] Adventure 2.17.2.

4 years ago
(updated 4 years ago)

Getting same message - Factorio version 0.17.63 and [Z] Adventure 2.17.2

4 years ago

I added:

        local function switchGUI(state, index, erase)

            ad.gui = ad.gui or {}
            if not state and not index and erase then
                for i,g in pairs(ad.gui) do
                    ad.gui[i].destroy()
                    ad.gui[i] = nil
                end

            elseif not state and ad.gui[index] then
                ad.gui[index].destroy()
                ad.gui[index] = nil

            elseif state and not ad.gui[index] then
               --function copied from elsewhere, emptied out zadv_area_race messages
            end

        end

to the BlowItUp() function around line 2034 in areas.lus. Seems to have fixed it.

4 years ago

I just had a look at the code, it seems to be much easier!

There is function that gets defined in the same scope as BlowItUp() at line 1981:

local function SwitchGUI(state, index, erase)

However, it gets called (rather: it doesn't) in line 2034 this way:

switchGUI(false, nil, true)

Notice the difference? Typo at the start of the function name! Change line 2034 to

SwitchGUI(false, nil, true)

and it should work! :-)

BTW: For some reason I can't reproduce the spamming in Factorio 0.17.75, and I don't have the old savegame anymore. So I couldn't really test it …

4 years ago

I noticed that too, here's the thing: in other functions it is lowercase. Not by accident. I did try to define it outside of the BlowItUp function, using 'local function', but it wasn't detecting it (I don't know much about Lua). I assume BlowItUp got called elsewhere, so the local function wasn't in scope at the time.

If SwitchGUI isn't producing an error, then I guess it's fine?

4 years ago
(updated 4 years ago)

I noticed that too, here's the thing: in other functions it is lowercase. Not by accident. I did try to define it outside of the BlowItUp function, using 'local function', but it wasn't detecting it (I don't know much about Lua). I assume BlowItUp got called elsewhere, so the local function wasn't in scope at the time.

There seems to be a table of defined areas. For each area, the definition is a table value that includes local functions. The error happens for Exchange Posts, which are defined from line 1874 to 2521.:

ret.area['exchange post'] = {
… 
}

So no matter how the other function names are spelled, the names in definition and call don't match, so there is an error. But the name shouldn't matter because it's a local function anyway. (Also, the naming convention changes: for up to Exchange Post, it's "SwitchGUI", later it's "switchGUI". Guess it happens that you lose track of such details when you have such amounts of code.)

If SwitchGUI isn't producing an error, then I guess it's fine?

The problem is, I can't reproduce the error even if I don't change anything! Even excluding all other area types and bumping up the probability didn't help.

4 years ago

Yeah... I found an exchange post that did work (though I couldn't use it because I didn't have the stuff and when I came back it was gone REEEEEEE). Otherwise there always seemed to be a weird hazard concrete area with two holes, which is what I believe to be an exchange post. Only had the errors happen in my current game, even though I've had the mod active for many. This was the first time I've also seen a working exchange post, so I'm wondering if another mod I'm using added them (it added a lot of things).

New response