Mercurial > wow > momit-suicide-kings
comparison Import.lua @ 3:a55f4f2a4603 tip
intial (real) commit!
| author | Kyle@Kyle-PC |
|---|---|
| date | Thu, 23 Feb 2012 00:34:43 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 2:37321677b4d9 | 3:a55f4f2a4603 |
|---|---|
| 1 --[[ | |
| 2 Title: Suicide Kings | |
| 3 Author: Brom | |
| 4 Version: 0.1 | |
| 5 ]] | |
| 6 | |
| 7 function SuicideKings:GetUIDFromName( name ) | |
| 8 | |
| 9 for uid,v in pairs( self.db.profile.roster ) do | |
| 10 if ( v["main"] == name ) then | |
| 11 return uid | |
| 12 end | |
| 13 end | |
| 14 | |
| 15 SuicideKings:Print( "Warning: could not find UID for " .. name ) | |
| 16 return 0 | |
| 17 | |
| 18 end | |
| 19 | |
| 20 function SuicideKings:ImportFromKSK() | |
| 21 | |
| 22 SuicideKings:Print( "-- Importing KonferSK Data --" ) | |
| 23 | |
| 24 --[[ | |
| 25 import rosters | |
| 26 ]]-- | |
| 27 | |
| 28 SuicideKings:Print( "Importing KonferSK roster..." ) | |
| 29 self.db.profile.roster = {} | |
| 30 | |
| 31 -- search for unique mains | |
| 32 for _,v in pairs( ksk.sortedusers ) do | |
| 33 if ( ksk:UserIsAlt(v.id) == false ) then | |
| 34 | |
| 35 -- generate unique key | |
| 36 local uid = SuicideKings:UID( self.db.profile.roster ) | |
| 37 | |
| 38 -- associate with main character key | |
| 39 self.db.profile.roster[uid] = {}; | |
| 40 self.db.profile.roster[uid]["main"] = ksk.users[v.id].name; | |
| 41 | |
| 42 -- debug | |
| 43 -- SuicideKings:Print( "Imported main: " .. ksk.users[v.id].name .. " (key = " .. uid .. ")" ) | |
| 44 | |
| 45 end | |
| 46 end | |
| 47 | |
| 48 -- search for alts | |
| 49 for _,v in pairs( ksk.sortedusers ) do | |
| 50 if ( ksk:UserIsAlt(v.id) == true ) then | |
| 51 | |
| 52 -- ksk data | |
| 53 local altName = ksk.users[v.id].name; | |
| 54 local mainIdx = ksk.users[v.id].main; | |
| 55 local mainName = ksk.users[mainIdx].name; | |
| 56 | |
| 57 -- find a main in our data with that name | |
| 58 local found = false | |
| 59 for uid,vv in pairs( self.db.profile.roster ) do | |
| 60 if ( vv["main"] == mainName ) then | |
| 61 found = true | |
| 62 | |
| 63 -- check for alts table | |
| 64 if ( not self.db.profile.roster[uid]["alts"] ) then | |
| 65 self.db.profile.roster[uid]["alts"] = {} | |
| 66 end | |
| 67 | |
| 68 -- associate alt name with character key | |
| 69 table.insert( self.db.profile.roster[uid]["alts"], altName ) | |
| 70 | |
| 71 -- debug | |
| 72 -- SuicideKings:Print( "Imported alt: " .. altName .. " (main = " .. vv["main"] .. " | key = " .. uid .. ")" ) | |
| 73 end | |
| 74 end | |
| 75 | |
| 76 -- debugging | |
| 77 if ( found == false ) then | |
| 78 SuicideKings:Print( "Warning: could not find main for " .. altName ) | |
| 79 end | |
| 80 | |
| 81 end | |
| 82 end | |
| 83 | |
| 84 --[[ | |
| 85 import lists | |
| 86 ]]-- | |
| 87 | |
| 88 SuicideKings:Print( "Importing KonferSK lists..." ) | |
| 89 self.db.profile.lists = {} | |
| 90 | |
| 91 -- get lists | |
| 92 for _,v in pairs( ksk.sortedlists ) do | |
| 93 | |
| 94 -- generate unique key | |
| 95 local uid = SuicideKings:UID( self.db.profile.lists ) | |
| 96 | |
| 97 -- ksk data | |
| 98 local listName = ksk.lists[v.id].name | |
| 99 local listUsers = ksk.lists[v.id].users | |
| 100 | |
| 101 -- associate with main character key | |
| 102 self.db.profile.lists[uid] = {}; | |
| 103 self.db.profile.lists[uid]["name"] = listName; | |
| 104 | |
| 105 -- get user ids | |
| 106 self.db.profile.lists[uid]["users"] = {} | |
| 107 for _,vv in pairs( listUsers ) do | |
| 108 local userName = ksk.users[vv].name; | |
| 109 local userId = SuicideKings:GetUIDFromName( userName ) | |
| 110 table.insert( self.db.profile.lists[uid]["users"], userId ) | |
| 111 end | |
| 112 | |
| 113 SuicideKings:Print( "Imported list: " .. listName ) | |
| 114 | |
| 115 end | |
| 116 | |
| 117 end |
