hkzorman / advanced_npc

Advanced NPC for Minetest, using mobs_redo API
Other
17 stars 5 forks source link

Problem with walk_to_pos (node_pos var) #57

Closed BrunoMine closed 6 years ago

BrunoMine commented 6 years ago
2018-06-11 17:10:39: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'sunos' in callback luaentity_Step(): ...Mods/minetest 0-5-0/bin/../builtin/common/vector.lua:66: attempt to index local 'pos2' (a nil value)
2018-06-11 17:10:39: ERROR[Main]: stack traceback:
2018-06-11 17:10:39: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../builtin/common/vector.lua:66: in function 'direction'
2018-06-11 17:10:39: ERROR[Main]:   ...nced_npc/executable/programs/builtin/walk_to_pos.lua:48: in function <...nced_npc/executable/programs/builtin/walk_to_pos.lua:12>
2018-06-11 17:10:39: ERROR[Main]:   (tail call): ?
2018-06-11 17:10:39: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:965: in function 'execute_process'
2018-06-11 17:10:39: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:1094: in function 'interrupt'
2018-06-11 17:10:39: ERROR[Main]:   ...npc/executable/instructions/builtin_instructions.lua:81: in function <...npc/executable/instructions/builtin_instructions.lua:76>
2018-06-11 17:10:39: ERROR[Main]:   (tail call): ?
2018-06-11 17:10:39: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:1376: in function 'execute'
2018-06-11 17:10:39: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:1408: in function 'execute'
2018-06-11 17:10:39: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:1461: in function 'execution_routine'
2018-06-11 17:10:39: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:2189: in function <...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:2121>
2018-06-11 17:10:39: ERROR[Main]:   (tail call): ?
2018-06-11 17:10:39: ERROR[Main]:   ...de Mods/minetest 0-5-0/bin/../mods/mobs_redo/api.lua:2579: in function <...de Mods/minetest 0-5-0/bin/../mods/mobs_redo/api.lua:2522>

This variable node_pos appears to return null when end_pos argument is a table. I immediately tried that include line

if not node_pos then node_pos = end_pos end

The error has stopped, but the NPC always looks in a steady direction (in this case, to the back.) after walking to a position, I do not know if this is normal.

hkzorman commented 6 years ago

The way I fixed this in my (yet uncommitted) code was:

if use_access_node == true and node_pos then

In this line

I think it works well. Let me know if you notice anything weird. I'm not entirely sure of the root cause of the issue and I still need to investigate, but above is an ok workaround.

BrunoMine commented 6 years ago

I updated my brach and made the change you suggested. Results

2018-06-20 13:58:08: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'sunos' in callback luaentity_Step(): ...npc/executable/instructions/builtin_instructions.lua:410: bad argument #1 to 'setyaw' (number expected, got table)
2018-06-20 13:58:08: ERROR[Main]: stack traceback:
2018-06-20 13:58:08: ERROR[Main]:   [C]: in function 'setyaw'
2018-06-20 13:58:08: ERROR[Main]:   ...npc/executable/instructions/builtin_instructions.lua:410: in function <...npc/executable/instructions/builtin_instructions.lua:399>
2018-06-20 13:58:08: ERROR[Main]:   (tail call): ?
2018-06-20 13:58:08: ERROR[Main]:   ...npc/executable/instructions/builtin_instructions.lua:524: in function <...npc/executable/instructions/builtin_instructions.lua:510>
2018-06-20 13:58:08: ERROR[Main]:   (tail call): ?
2018-06-20 13:58:08: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:1376: in function 'execute'
2018-06-20 13:58:08: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:1408: in function 'execute'
2018-06-20 13:58:08: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:1461: in function 'execution_routine'
2018-06-20 13:58:08: ERROR[Main]:   ...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:2189: in function <...Mods/minetest 0-5-0/bin/../mods/advanced_npc/npc.lua:2121>
2018-06-20 13:58:08: ERROR[Main]:   (tail call): ?
2018-06-20 13:58:08: ERROR[Main]:   ...de Mods/minetest 0-5-0/bin/../mods/mobs_redo/api.lua:2579: in function <...de Mods/minetest 0-5-0/bin/../mods/mobs_redo/api.lua:2522>
2018-06-20 13:58:08: ACTION[Server]: 888 leaves game. List of players: 
Loaded texture: [...]/textures/base/pack/menu_header.png
Loaded texture: [...]/games/minetest_game/menu/header.png
hkzorman commented 6 years ago

@BrunoMine I updated the dev branch of your mod and tested on my local. Found no issues (except for one NPC not doing anything).

I have pushed all my code in to the clean_api branch. Can you test with this latest push?

BrunoMine commented 6 years ago

Problem fixed!