i am basically writing a recursive function that goes into each dictionary stored in the entire table to search for a specific animation array by simply only using the index. this is all inside a modulescript
You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve?
the recursive function currently only returns nil, and i want to return the medium_s
array in this instance. (not one given value, the whole table of {"ids are here", etc}
)
- What is the issue?
see above; by the way, the given value for AnimationId
is medium_s
(string). i have typechecked both of them like a million times
- What solutions have you tried so far?
the function successfully can go into each dictionary and read out all expected tables, i’ve confirmed this with print()
checks…
(result):
…and for some reason, the yellow highlighted output (given by the warn()
in the for loop that is supposed to only run if the array i wanted was found ran anyways, even though returning it still yields nil
i saw some stuff about for loops being a non-callback and other loopholes others have found so here’s a list of stuff that hasn’t worked:
- making a table in the function and inserting the array in there and then returning
that_table[1] or nil
. returns nil. - making a variable at the top and then setting to the found array,
break
ing and return said variable. returns nil - changing
returns
on the function callback for theelse
part of the if statement by removing/adding it, same for thetostring()
s, does nothing to change output - changing
cycling_table
to be a general function parameter whereani_manager.ids
would be inserted manually in parenthesis, still does not change it - i can’t make a global variable outside the function because this is a module to be used by all clients to quickly generate animations, so yea
here’s the code piece
ani_manager.ids = {
combat = {
medium_s = {
"ids are here",
"ids are here"
},
light_s = {},
heavy_s = {}
},
casual = {
idle = "",
confirm = "",
deny = ""
}
}
function ani_manager.GetAnimationArray(AnimationId, OverridingTable)
local cycling_table = OverridingTable or ani_manager.ids
for index, array in pairs(cycling_table) do
if tostring(index) == tostring(AnimationId) then
return array
elseif type(array) == "table" then
return ani_manager.GetAnimationArray(AnimationId, array)
end
end
return nil -- returns nil always for some reason
end
i’ve tried everything i can really think of for this and it still isn’t giving anything back. i know it’s this code segment here because when i put it the table in the function for running animations manually the animations play as intended, don’t know if it’s a scope issue or what. thoughts?