[SOLVED!] Unable To Detect Follower Type in LUA

Lua:
addHook("PlayerSpawn", function()
    for player in players.iterate do
        chatprint(#player)
        chatprint(followers[#player].name)
        chatprint(player.follower.name)
        chatprint("----")
    end
end)

When I run the mod that this code is in, I get "attempt to index field 'follower' (a nil value)" on the line with chatprint(player.follower.name), and chatprint(followers[#player].name) just prints a pre-defined list of 16 followers no matter who has what (the first 16 followers that were added to the game?)

I suspect the "nil value" result has to do with the follower entity not being loaded in yet. What would the solution/workaround be to detect what follower each player chose?
 
I tried waiting a few frames (set up a timer in PlayerSpawn, then incremented/detected it in PlayerThink), and now it detects my follower, but it still can't get its name. bad argument #1 to 'chatprint' (string expected, got nil) from chatprint(p.follower.name)
It's a step forward, but I'm still unable to detect what type of follower a player has.
Post automatically merged:

I looked in the gitlab repository for the game's source code and found K_GetEffectiveFollowerSkin(p). However, when I tried to use this function, all it did was spit out another error at me: WARNING: addons\ketchupkid.pk3|lua/object.lua:59: attempt to call global 'K_GetEffectiveFollowerSkin' (a nil value). This is especially surprising since K_GetEffectiveFollowerColor works fine in the same script.
 
Last edited:
Back
Top