From c779ed617e5a65353b504159e00a75f74f72851a Mon Sep 17 00:00:00 2001 From: Seebs Date: Sat, 24 Mar 2012 13:04:48 -0500 Subject: [PATCH] Various updates. --- ChangeLog.txt | 9 +++++++++ LibAccounts.lua | 9 +++++---- Makefile | 2 +- ReadMe.txt | 7 +++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 367a895..85c9dde 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,12 @@ +2012/03/24: + * Modify available list to include both numeric and charname + keys. + * Call this 0.5. + +2012/01/08: + * Fix handling of a second shard once you've already shown up + on one. + 2012/01/07: * Fix dependencies/embed so they actually work. * 0.3 diff --git a/LibAccounts.lua b/LibAccounts.lua index 11024bf..fd32150 100644 --- a/LibAccounts.lua +++ b/LibAccounts.lua @@ -40,6 +40,8 @@ function Accounts.table_init() end if not LibAccountsGlobal.shards then LibAccountsGlobal.shards = {} + end + if not LibAccountsGlobal.shards[shard] then LibAccountsGlobal.shards[shard] = { chars = {}, accounts = {}, @@ -94,10 +96,8 @@ end function Accounts.available_p(charname, acct_only) local availables = Accounts.available_chars(acct_only) charname = string.lower(charname) - for _, row in ipairs(availables) do - if string.lower(row.char) == charname then - return true - end + if availables[charname] then + return true end return false end @@ -114,6 +114,7 @@ function Accounts.populate(availables, visited, acctid, acct_only) for char, faction in pairs(Accounts.here.accounts[acctid]) do factions[faction] = true table.insert(availables, { char = char, faction = faction, acctid = acctid }) + availables[char] = { faction = faction, acctid = acctid } end if not acct_only then for other_acct, chars in pairs(Accounts.here.accounts) do diff --git a/Makefile b/Makefile index 84aec7a..ea94de4 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=0.3 +VERSION=0.5 PACKAGE=LibAccounts EMBEDS=getopt diff --git a/ReadMe.txt b/ReadMe.txt index bdef1df..fea5166 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -19,10 +19,12 @@ The other useful function, of interest mostly to altoholics: This produces a table: { char = char, faction = faction, acctid = acctid }, ... + char = { faction, acctid }, ... of characters who are "available". That's every character on this account, plus any characters on other accounts who are of the same faction as at -least one character on this account, and so on recursively. +least one character on this account, and so on recursively. There's numeric +keys for a complete list, or you can just index by a character. So if you have account #1: Defiant1 @@ -57,7 +59,8 @@ Intentionally exposed API: Yields { char, faction, acctid } tuples for this shard which are on the current account or reachable from characters on this account. If acct_only is truthy, checks only - characters on this account. + characters on this account. Also char = { faction, acctid } + tuples. Library.LibAccounts.acct_of(char) Returns the acctid, if any, that has the named character (or player if char is nil)