[b90-beta] movedOverToken bug

Confirmed bugs should get a single post here. Check the READ ME FIRST sticky thread for the format.

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice, MapTool BugReport Manager

Forum rules
Posts that do not conform to the READ ME FIRST sticky thread are subject to deletion.
Post Reply
User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

[b90-beta] movedOverToken bug

Post by wolph42 »

this is really hard to describe and even harder to reproduce but its happening.

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)]
 
is part of a main routine that cycles through all special pads in the bag of tricks.

Point is is that the 'pause' results in this:
Untitled picture.png
Untitled picture.png (31.17 KiB) Viewed 821 times
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.

Lee
Dragon
Posts: 958
Joined: Wed Oct 19, 2011 2:07 am

Re: [b90-beta] movedOverToken bug

Post by Lee »

The question is: Does this break anything in your code? Also, any calls to deferred macro functions? The thing is, using the pause trick with the parser might generate some disparate results since the call to the input function might have caught it in the middle of processing results.

This is one of the reasons why I earmarked development of a proper watch feature where the current context being processed will be displayed after the parser properly runs through it. I got the architecture for it all mapped out but I've deferred development since my initial goals are to attract casual and technically "unsavvy" users.

Anyway, if it breaks anything, I'll take a look.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: [b90-beta] movedOverToken bug

Post by wolph42 »

It definitely breaks my code and it took me an age to figure out why. Point is, to retrieve an intersection of that with eg the ending coords of a token from last path I use json.contains(). But as this result differs from the usual x,y setup it will always return false: you won't find {x:0,y:0} in [{x1:0,y1:0}]

The workaround I found for this issue is to not use switchToken earlier in the code.

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: [b90-beta] movedOverToken bug

Post by aliasmask »

Is the x1:y1 x2:y2 result normal, or is that something new. Is it generated with Wiki: movedOverToken()? If not, what is generating that?

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: [b90-beta] movedOverToken bug

Post by wolph42 »

aliasmask wrote:Is the x1:y1 x2:y2 result normal, or is that something new. Is it generated with Wiki: movedOverToken()? If not, what is generating that?
it is generated by movedOverToken I *think* it has always been there. It roughly boils down to (again I *think*, did not test this seperately):
switchToken(John)
path = getLastPath()
movedOverToken(roof, path)
--> results in x,y coords
swtichToken(Marry)
movedOverToken(roof, path)
--> results in x1,y1,x2,y2 coords.
x2 is the same as the next x1 (so the end and startpoints are the same) e.g.[{x1:0}, {x2:5}, {x1:5}, {x2:10}, {x1:10}, {x2:15}] etc. while the usual output is [{x:0}, {x:5}, {x:10}, {x:15}] (I left out the y and the quotes)

edit: not confirmed. moving the switchToken() in the bag of tricks code did the trick, but in a clean campaign I cannot reproduce it. So there's more going on.

Post Reply

Return to “Bug Reports”