Skip to content

SMODS.get_table_keys#1207

Closed
InvalidOS wants to merge 1 commit intoSteamodded:mainfrom
InvalidOS:patch-1
Closed

SMODS.get_table_keys#1207
InvalidOS wants to merge 1 commit intoSteamodded:mainfrom
InvalidOS:patch-1

Conversation

@InvalidOS
Copy link
Copy Markdown
Contributor

Turns the local get_keys function from SMODS.upgrade_poker_hands into a separate utility function, SMODS.get_table_keys, since it can be useful in some circumstances for modders to have access to. It takes a table as input and returns a table containing all of that table's keys as values.

Additional Info:

  • I didn't modify api's or I've made a PR to the wiki repo.
  • I didn't modify api's or I've updated lsp definitions.
  • I didn't make new lovely files or all new lovely files have appropriate priority.

Comment thread src/utils.lua
-- Gets all keys from a table
function SMODS.get_table_keys(t)
local keys = {}
for k, _ in pairs(t) do
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if type(t) ~= "table" then return keys end

@Aurelius7309
Copy link
Copy Markdown
Member

The local get_keys function has no reason to exist in the first case. In both of the cases where it's used, other tables containing the constructed information already exist in the global state. Neither do I see any reason for smods to have this kind of util function, given you probably need to revise your data structures if you need it, and it's neither complicated nor tedious to write. Closing in favor of using pre-existing data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants