get("#515") -- splitLines serpent = grab("#158") get("#532") -- getBridgeMap get("#533") -- replaceSnippetIDs text = getSnippet("#2000291") lines = splitLines(text) function tableToLine(snippet) return serpent.line(snippet, {comment=0}) end for i=1, #lines do line = lines[i] local _, _, _needBridgeID, _sourceID, _masterBridgeID = line:find("^(#%d+) %- Need bridge from (#%d+) following master bridge (#%d+)") if _needBridgeID then needBridgeID, sourceID, masterBridgeID = _needBridgeID, _sourceID, _masterBridgeID masterBridgeTitle = getSnippetTitle(masterBridgeID) idmap = getBridgeMap(masterBridgeID) print("-- id map for master bridge "..masterBridgeID..": "..tableToLine(idmap)) end local _, _, verdict = line:find("^ *Your verdict: *(.*)") if verdict then print("-- "..needBridgeID.." / "..sourceID..": "..verdict) hasBridge = hasNTTitle("Bridge from "..sourceID.." to % following master bridge "..masterBridgeID) if hasBridge then print("-- has bridge, skipping") elseif verdict == 'skip' or verdict == 'invalidated' then -- Invalidate the "Need bridge" snippet snippet = {type='nt', title='Invalidate '..needBridgeID, text='Verdict was: '..verdict} print("lua [[ ") print(" create "..tableToLine(snippet)) print("]]") elseif verdict == 'copy verbatim' then -- assume source type is nt sourceTitle = getSnippetTitle(sourceID) sourceText = getSnippet(sourceID) destTitle = replaceSnippetIDs(sourceTitle, idmap) destText = replaceSnippetIDs(sourceText, idmap) snippet = {type='nt', title=destTitle, text=destText} print("lua [[ ") print(" destID = create "..tableToLine(snippet)) print(" create {type='nt', title='Bridge from "..sourceID.." to '..destID..' following master bridge "..masterBridgeID.."', text=''}") print("]]") end end end
Began life as a copy of #2000292
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: | #531 |
Snippet name: | Process questionnaire |
Eternal ID of this version: | #531/1 |
Text MD5: | 70b8b3b33316433de7ce7ed6373db903 |
Author: | stefan |
Category: | |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-03-15 03:46:07 |
Source code size: | 1969 bytes / 51 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 768 / 187 |
Referenced in: | [show references] |