mt-mods / technic

Technic mod for Minetest
18 stars 25 forks source link

nil index with cable plate #305

Closed SwissalpS closed 7 months ago

SwissalpS commented 1 year ago
AsyncErr: Lua: Runtime error from mod 'technic' in callback item_OnPlace(): table index is nil
stack traceback:
    [C]: in function 'rawset'
    .../20220909_2250/minetest/bin/../builtin/common/vector.lua:21: in function '__newindex'
    ...bin/../mods/technic/technic/machines/register/cables.lua:102: in function <...bin/../mods/technic/technic/machines/register/cables.lua:94>

I ran into this when placing a cable plate on top of a travelnet. (I was doing /area_pos set and missed a node, had a cable plate in hand so tried to place that)

possibly a travelnet top node issue. possibly good to fix here as there may be other such nodes.

S-S-X commented 1 year ago

pretty sure pointed_thing something something making index to be out of bounds:

https://github.com/mt-mods/technic/blob/fd2844ea441b55160b54f330e2fe6b9fcbe013da/technic/machines/register/cables.lua#L95-L97

I guess pointed_thing above/under is too far which isn't expected, could normalize those to give give just direction instead of distance (which is assumed to be -1, 0 or 1 each axis).

Not sure but it might have something to do with over sized node and might happen with other things that use over sized nodes.

S-S-X commented 7 months ago

Note that applied fix prevents certain placements where actual node position and attempted placement position differs on more than one dimension. It might be a bit confusing in game when it happens but thankfully there's not that real cases where it happens.