Skip to content

Instantly share code, notes, and snippets.

@fireundubh
Created September 23, 2019 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fireundubh/72950d8de51fd44c3bc916e25ec3fc94 to your computer and use it in GitHub Desktop.
Save fireundubh/72950d8de51fd44c3bc916e25ec3fc94 to your computer and use it in GitHub Desktop.
local percentCompleted = 0;
if isComplete then
percentCompleted = 1;
else
-- check for nil
if objectives then
for i, objective in pairs(objectives) do
-- check for nil
if objective and objective.numFulfilled and objective.numRequired then
percentCompleted = percentCompleted + (objective.numFulfilled / objective.numRequired);
end
end
percentCompleted = percentCompleted / table.getn(objectives);
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment