Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #532 // Make bridge map (getBridgeMap)

Lua code

get("#349") -- table functions

function getBridgeMap(masterBridge)
  local title = getSnippetTitle(masterBridge)
  local _, _, masterSourceID, masterDestID = title:find("from (#%d+) to (#%d+)")
  
  local idmap = {}
  idmap[masterSourceID] = masterDestID
  
  local refs = findNTTitle("Need bridge from % following master bridge "..masterBridge)
  for r in all(refs) do
    local title = getSnippetTitle(r)
    local _, _, sourceID = title:find("^Need bridge from (#%d+)")
    idmap[sourceID] = '<unbridged '..sourceID..'>'
  end
  
  local refs = findNTTitle("A bridge from % following master bridge "..masterBridge)
  for r in all(refs) do
    local title = getSnippetTitle(r)
    local _, _, sourceID, destID = title:find("^A bridge from (#%d+) to (#%d+)")
    idmap[sourceID] = destID
  end
  
  return idmap
end

test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #532
Snippet name: Make bridge map (getBridgeMap)
Eternal ID of this version: #532/1
Text MD5: 7816d61affda4c468e0cff515adfe8f3
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-03-15 03:47:19
Source code size: 841 bytes / 25 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 621 / 140
Referenced in: [show references]