HybridDog / nether-pack

migrated to codeberg
https://codeberg.org/HybridDog/nether-pack
Other
5 stars 8 forks source link

init.lua:778: attempt to call upvalue 'set' (a nil value) - in function 'grow_tree' #7

Closed Megaf closed 6 years ago

Megaf commented 6 years ago
[nether] generates at: x=[-32; 47]; y=[-19952; -19873]; z=[768; 847]
[nether] nodes set after ca. 1.01s
[nether] trees set after ca. 0.00s
<WARNING> 2017-12-20 16:06:07: [Emerge-0] Assignment to undeclared global "area" inside a function at ...r/BinMegafServer/bin/../mods/nether-pack/nether/init.lua:197.
<WARNING> 2017-12-20 16:06:07: [Emerge-0] Assignment to undeclared global "nodes" inside a function at ...r/BinMegafServer/bin/../mods/nether-pack/nether/init.lua:198.
[nether] map updated after ca. 0.39s
[nether] done after ca. 1.40s
[nether] generates at: x=[-32; 47]; y=[-19952; -19873]; z=[768; 847]
[nether] nodes set after ca. 1.04s
[nether] trees set after ca. 0.00s
[nether] map updated after ca. 0.40s
[nether] done after ca. 1.44s
[nether] generates at: x=[-32; 47]; y=[-19952; -19873]; z=[1008; 1087]
[nether] nodes set after ca. 1.40s
[nether] generates at: x=[-32; 47]; y=[-19952; -19873]; z=[1008; 1087]
[nether] nodes set after ca. 0.93s
[biome_lib] Stand by, playing out the rest of the aircheck mapblock log
(there are 2 entries)...
[biome_lib] Stand by, playing out the rest of the no-aircheck mapblock log
(there are 2 entries)...
End log output over terminal (no stdout/stderr backlog during that)
========================
2017-12-20 16:06:41: ERROR[Main]: ServerError: AsyncErr: Lua: finishGenRuntime error from mod 'nether' in callback environment_OnGenerated(): ...r/BinMegafServer/bin/../mods/nether-pack/nether/init.lua:778: attempt to call upvalue 'set' (a nil value)
2017-12-20 16:06:41: ERROR[Main]: stack traceback:
2017-12-20 16:06:41: ERROR[Main]:       ...r/BinMegafServer/bin/../mods/nether-pack/nether/init.lua:778: in function 'grow_tree'
2017-12-20 16:06:41: ERROR[Main]:       ...r/BinMegafServer/bin/../mods/nether-pack/nether/init.lua:620: in function <...r/BinMegafServer/bin/../mods/nether-pack/nether/init.lua:359>
2017-12-20 16:06:41: ERROR[Main]:       ...afServer/BinMegafServer/bin/../builtin/game/register.lua:412: in function <...afServer/BinMegafServer/bin/../builtin/game/register.lua:392>
paramat commented 6 years ago

Line 695 local set = vector.set_data_to_pos but that vector function doesn't exist in bultin.

Megaf commented 6 years ago

@paramat I do have this https://github.com/HybridDog/vector_extras

paramat commented 6 years ago

https://github.com/HybridDog/vector_extras/blob/master/legacy.lua#L15

paramat commented 6 years ago

Best add that function to the nether mod, delete https://github.com/HybridDog/nether-pack/blob/master/nether/init.lua#L695 and replace it with:

local function set(tab, z,y,x, data)
    if tab[z] then
        if tab[z][y] then
            tab[z][y][x] = data
            return
        end
        tab[z][y] = {[x] = data}
        return
    end
    tab[z] = {[y] = {[x] = data}}
end
paramat commented 6 years ago

Oh and do the same for lines 696 and 697 which likely cause similar crashes. Remember to remove the deprecation messages. The vector extras mod was updated without then updating the nether mod, this is why it's best to keep the nether mod self-contained.

Megaf commented 6 years ago

Testing

paramat commented 6 years ago

In nether/init.lua replace line 696 with:

local function get(tab, z,y,x)
    local data = tab[z]
    if data then
        data = data[y]
        if data then
            return data[x]
        end
    end
end

Replace line 697 with:

local function remove(tab, z,y,x)
    if get(tab, z,y,x) == nil then
        return
    end
    tab[z][y][x] = nil
    if not next(tab[z][y]) then
        tab[z][y] = nil
    end
    if not next(tab[z]) then
        tab[z] = nil
    end
end
paramat commented 6 years ago

Seems my suggestion above is causing problems, i can't be bothered to attend to this anymore. @HybridDog over to you.

HybridDog commented 6 years ago

I removed these functions from vector_extras because they're inefficient. When I made them I didn't know yet that moving things from and to memory is a lot slower than calculating and I didn't know how the lua table is implemented. tab[z][y][x] is implemented as three hash maps and their three hash value calculations, whereas tab[minetest.hash_node_position(pos)] rather represents one hashmap and two hash value calculations. # The proper fix is using tab[minetest.has_node_position{x=x, y=y, z=z}] instead of set and get everywhere.

Megaf commented 6 years ago

Well, now that these thing were fixed my fork doenst have a reason to exist. Will test how nether-pack is doing and if everything is fine I will delete my fork.

Megaf commented 6 years ago

@HybridDog Thanks for sorting this out. @paramat Thanks for all the help and help in getting my server going again. Closing this now, will reopen if bug still present.