2020-12-27 15:16:31: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'playerfactions' in callback on_chat_message(): ...es/minetest/games/mesecraft/mods/playerfactions/init.lua:259: attempt to get length of local 'player_factions' (a nil value)
2020-12-27 15:16:31: ERROR[Main]: stack traceback:
2020-12-27 15:16:31: ERROR[Main]: ...es/minetest/games/mesecraft/mods/playerfactions/init.lua:259: in function 'func'
2020-12-27 15:16:31: ERROR[Main]: /usr/share/games/minetest/builtin/game/chat.lua:69: in function
2020-12-27 15:16:31: ERROR[Main]: /usr/share/games/minetest/builtin/game/register.lua:429: in function
2020-12-27 15:16:31: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'playerfactions' in callback on_chat_message(): ...es/minetest/games/mesecraft/mods/playerfactions/init.lua:259: attempt to get length of local 'player_factions' (a nil value)
2020-12-27 15:16:31: ERROR[Main]: stack traceback:
2020-12-27 15:16:31: ERROR[Main]: ...es/minetest/games/mesecraft/mods/playerfactions/init.lua:259: in function 'func'
2020-12-27 15:16:31: ERROR[Main]: /usr/share/games/minetest/builtin/game/chat.lua:69: in function </usr/share/games/minetest/builtin/game/chat.lua:48>
2020-12-27 15:16:31: ERROR[Main]: /usr/share/games/minetest/builtin/game/register.lua:429: in function </usr/share/games/minetest/builtin/game/register.lua:413>
local player_factions = factions.get_player_factions(name) or {}
Also, We should not execute the "else" of that following if statement, because if player_factions = nil, then the player is not in many factions; they are in NO factions. My fix sends a message to them "You are not in any factions!" Instead, and prevents running the wrong message.
this is caused by a player not being in a faction... thus
factions.get_player_factions(name) returns nil.
When it does, we actually want an empty list so we can still run #player_factions on it (to return 0 instead of throwing an error)
"... or {} " sets player_factions to {} if get_player_factions(name) returns nil
Line 258 should read:
local player_factions = factions.get_player_factions(name) or {}
Also, We should not execute the "else" of that following if statement, because if player_factions = nil, then the player is not in many factions; they are in NO factions. My fix sends a message to them "You are not in any factions!" Instead, and prevents running the wrong message.
-------------
this is caused by a player not being in a faction... thus
factions.get_player_factions(name) returns nil.
When it does, we actually want an empty list so we can still run #player_factions on it (to return 0 instead of throwing an error)
"... or {} " sets player_factions to {} if get_player_factions(name) returns nil
The PR with the protector fix also fixes this:
https://notabug.org/MeseCraft/mesecraft/pulls/17/commits
2020-12-27 15:16:31: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'playerfactions' in callback on_chat_message(): ...es/minetest/games/mesecraft/mods/playerfactions/init.lua:259: attempt to get length of local 'player_factions' (a nil value) 2020-12-27 15:16:31: ERROR[Main]: stack traceback: 2020-12-27 15:16:31: ERROR[Main]: ...es/minetest/games/mesecraft/mods/playerfactions/init.lua:259: in function 'func' 2020-12-27 15:16:31: ERROR[Main]: /usr/share/games/minetest/builtin/game/chat.lua:69: in function
2020-12-27 15:16:31: ERROR[Main]: /usr/share/games/minetest/builtin/game/register.lua:429: in functionLine 258 should read:
local player_factions = factions.get_player_factions(name) or {}
Also, We should not execute the "else" of that following if statement, because if player_factions = nil, then the player is not in many factions; they are in NO factions. My fix sends a message to them "You are not in any factions!" Instead, and prevents running the wrong message.
this is caused by a player not being in a faction... thus factions.get_player_factions(name) returns nil. When it does, we actually want an empty list so we can still run #player_factions on it (to return 0 instead of throwing an error)
"... or {} " sets player_factions to {} if get_player_factions(name) returns nil
The PR with the protector fix also fixes this:
https://notabug.org/MeseCraft/mesecraft/pulls/17/commits
You forgot a "then" statement after your "elseif".
Otherwise it worked and seemed to do the trick.