[Lua] How could "for k, v in pairs(someTable) do" returns k = nil, v = 0 ??? (solved)

Gedemon

Modder
Super Moderator
Joined
Oct 4, 2004
Messages
11,499
Location
France
Edit : solved, of course I'm doing a resourceKey = tostring(resourceID) earlier in the code... :o

Spoiler :
I'm looking at a log that I don't understand, I though that nil key weren't possible in Lua, yet I have this in my code:

Code:
    for resourceKey, value in pairs(data.Stock[turnKey]) do
        print("resourceKey = " .. resourceKey .. " value = "..tostring(value))
    end

and that in the log:

Code:
CityBannerManager: resourceKey = 50 value = 43
CityBannerManager: resourceKey = 7 value = 60
CityBannerManager: resourceKey = 1 value = 80
CityBannerManager: resourceKey = 51 value = 714
CityBannerManager: resourceKey = 49 value = 23.33
CityBannerManager: resourceKey = 8 value = 80
CityBannerManager: resourceKey = 0 value = 10
CityBannerManager: resourceKey = 42 value = 80
CityBannerManager: resourceKey = nil value = 0
 
Last edited:
Top Bottom