Code: Select all
[h:'<!-- ---------------------------------------- LINKED ----------------------------------------------- -->']
<!-- abort if moving on or over the pad -->
[linkedTriggered = movedOverToken(padName,lastPath)]
[h:startOnPad = if(json.contains(linkedTriggered,startingLocation), 1, 0)]
[h:endOnPad = if(json.contains(linkedTriggered,currentLocation), 1, 0)]
<!-- "Linked 1 Roof 2" == "Match1 Match2 Match3 Match4" -->
[h:linkId = getGroup(strfind(padName, "[^\\s]+"), 2, 0)]
[h:startLinkId = if(startOnPad, linkId, startLinkId)]
[h:endLinkId = if(endOnPad, linkId, endLinkId)]
[switchToken(padName)]
[linkedAll = getProperty("w42.bot.linked")]
[linkedBridge = getProperty("w42.bot.linkedBridge")]
[linkedTunnel = getProperty("w42.bot.linkedTunnel")]
[linkedSpecial = lower(getProperty("w42.bot.linkedSpecial"))]
<!-- first check if you know what the end pad is and if not, figure it out. This is needed to make the right decision -->
[if(startOnPad && endLinkId == ""), CODE:{
[foreach(pad, linkedAll), CODE:{
[tlinkedTriggered = movedOverToken(pad,lastPath)]
[endLinkId = if(json.contains(tlinkedTriggered,currentLocation), linkId, endLinkId)]
[pause("startOnPad","lastPath","pad","padName","linkedTriggered","tlinkedTriggered","endLinkId","linkId","currentLocation")]
}]
};{}]
[switchToken(tok)]
Point is is that the 'pause' results in this: as you can see movedOvertoken is run twice for EXACTLY the same pad and lastPath, but it gives two different results.
beside that, for some reason it also changes the result from a x,y into a x1,y1,x2,y2 result. AFAIK it should always result in x,y.
edit: it has something to do with the switchToken that takes place between the two movedOverToken calls. Even though this *should* not be of any influence.