LUA Debug

Your forum for all discussions around Modding.
User avatar
TheFlogger968
Posts: 16
Joined: Fri Nov 25, 2022 2:04 pm
Location: Bruxelles (BE)

LUA Debug

Post by TheFlogger968 »

Hello,
I am a beginner in LUA and I have a problem with debugging.
I have this error:

Code: Select all

2023-03-15 18:49 Error: Running LUA method 'update'.
dataS/scripts/placeables/specializations/PlaceableObjectStorage.lua(528): attempt to compare number with boolean
But I don't know what is the number after ".lua".

If you have any tips to debug the lua code in FS22, it would help me a lot.

Thanks in advance,

Florian
User avatar
Jason06
Posts: 261
Joined: Sun Sep 06, 2020 11:59 am
Location: Essen (D)

Re: LUA Debug

Post by Jason06 »

Hello Florian,

the number shows the line in the lua-code where the error occurs.

In this case it points to a lua script of the game itself ("dataS/scrtipts/..."), so you will have to find out which mod script triggers an in-game-function with improperly set variables: A used variable has to be a number type and is boolean or vice versa.

Regards,
Martin
aka Glowin / Glowins Modschmiede
MacBook 16'' 2019 (2,4 GHz Intel i9), Nimbus+ Controller, Realismus-Fan und Hobby-Scripter
User avatar
TheFlogger968
Posts: 16
Joined: Fri Nov 25, 2022 2:04 pm
Location: Bruxelles (BE)

Re: LUA Debug

Post by TheFlogger968 »

Jason06 wrote: Tue Mar 21, 2023 10:16 am Hello Florian,

the number shows the line in the lua-code where the error occurs.

In this case it points to a lua script of the game itself ("dataS/scrtipts/..."), so you will have to find out which mod script triggers an in-game-function with improperly set variables: A used variable has to be a number type and is boolean or vice versa.

Regards,
Martin
Hello Martin,

Thank you for your answer.
That's what I had in mind.

Unfortunately, this line is empty.
I don't know if it's because the file given in the zip source game is incomplete or if the numbering of notepad++ is incomplete.

Image

Thanks and Regards,
Florian
User avatar
Jason06
Posts: 261
Joined: Sun Sep 06, 2020 11:59 am
Location: Essen (D)

Re: LUA Debug

Post by Jason06 »

Then this line isn't publicly available, which makes debugging more difficult.
If you have a mod in mind, try out if the error occurs without it. Else you have to try out your mods one by one, until you find the one causing this error.

If it's in a script of your own, check the types of your variables used in function calls.
aka Glowin / Glowins Modschmiede
MacBook 16'' 2019 (2,4 GHz Intel i9), Nimbus+ Controller, Realismus-Fan und Hobby-Scripter
User avatar
TheFlogger968
Posts: 16
Joined: Fri Nov 25, 2022 2:04 pm
Location: Bruxelles (BE)

Re: LUA Debug

Post by TheFlogger968 »

I'm just trying to make rakes with the new autoload storage feature.

Code: Select all

<storageAreas>
            <storageArea startNode="storageArea1Start" endNode="storageArea1End"/>
            <storageArea startNode="storageArea2Start" endNode="storageArea2End"/>
</storageAreas>
Looking at the XML schema record, it seemed possible to have several storage areas.

Code: Select all

    schema:register(XMLValueType.NODE_INDEX, basePath .. ".objectStorage.storageAreas.storageArea(?)#startNode", "Start node")
    schema:register(XMLValueType.NODE_INDEX, basePath .. ".objectStorage.storageAreas.storageArea(?)#endNode", "End node")
I couldn't find any documentation about the "xmlFile:iterate" function
https://gdn.giants-software.com/documen ... nction=595

I suppose it loads all the storages area.

Code: Select all

self.xmlFile:iterate("placeable.objectStorage.storageAreas.storageArea", function(index, areaKey)
        local storageArea = {}
        storageArea.startNode = self.xmlFile:getValue(areaKey .. "#startNode", nil, self.components, self.i3dMappings)
        storageArea.endNode = self.xmlFile:getValue(areaKey .. "#endNode", nil, self.components, self.i3dMappings)
        if storageArea.startNode ~= nil and storageArea.endNode ~= nil then
            local _
            storageArea.sizeX, _, storageArea.sizeZ = localToLocal(storageArea.endNode, storageArea.startNode, 0, 0, 0)
            table.insert(spec.storageArea.area, storageArea)
        else
            Logging.xmlWarning(self.xmlFile, "Incomplete spawn area definition in '%s'", areaKey)
        end
    end)
It doesn't seem possible to have multiple storage areas, so I'm trying to understand why and if possible modify the lua to add this feature.

I'll have to find a small LUA project to start with.
Post Reply