Error: Attempt to invoke bookmark for [Function]

###What does this error mean? Error: Attempt to invoke bookmark for [function]


All of a sudden I am getting this error a lot: Error: Attempt to invoke bookmark for [Function]. I do know know what causes the error, the error appears most often when I use hero.say().
Thank you.
-Cheers!

1 Like

Can you provide some code for which this is happening? We switched to a new interpreter and this error looks like itā€™s trying to tell you that youā€™re calling a function which you shouldnā€™t have access to in some form.

1 Like

I have included my full code under the ā€œFull Codeā€ spoiler. The particular problem at the momment happens in this funciton:

def histListFn(hist):
    hero.say("histListFn")
    histList = []
    for h in hist:
        histList.append(h)
    hero.say(histList)

The last line, hero.say(histList) returns the error. I do not see any reason for an error, although I could be mistaken. Though I can not remember, I know I have found this error a lot recently and had to stop developing my code. Thank you for takeing a look.
-Cheers

Full Code
###-GENERATES-NONE-1to8-HISTOGRAM-###
def blankHistFn():
    blankHist = {}
    for i in range(1, 9):
        blankHist[i] = 0
    return blankHist

###-CONVERST-BOOLIAN-TO-INTERGER-###
def boolInt(boolVar):
    intVar = 0
    if boolVar: intVar = 1
    return intVar

###-RETURNS-THE-OCTANT-VALUE-PER-ITEM-###
def octantFn(item):
    octantOpt = [([1, 2], [8, 7]), ([4, 3], [5, 6])]
    xPos = item['x']
    yPos = item['y']
    octant = octantOpt[boolInt(xPos < 0)][boolInt(yPos < 0)][boolInt(abs(xPos) < abs(yPos))]
    return octant   

###-RETURNS-LIST-OF-ITEMS-W/-0,0-AT-HERO-###
def heroCentered(stockItems, heroPos):
    heroCentricItems = [] 
    for item in stockItems: 
        nuePos = item.pos.subtract(heroPos)
        heroCentricItems.append(nuePos)
    #hero.say(heroCentricItems)
    #return heroCentricItems

###-FILLS-HISTOGRAM-WITH-SET-DATA-###
def itemHistogram(itemSet):
    itemHist = blankHistFn()
    for item in itemSet:
        octantVal = octantFn(item)
        itemHist[octantVal] += 1
        #hero.say(itemHist[octantVal])
    return itemHist

def highHistFn(hist):
    highHist = None
    for h in hist:
        hero.say(h)
        if hist[h] > hist[highHist]:
            hero.say("nue highest")
            highHist = h
            
    #hero.say(hist[high])
    return highHist

def histListFn(hist):
    hero.say("histListFn")
    histList = []
    for h in hist:
        histList.append(h)
    hero.say(histList)
    

###-MASTER-FUNCTION-SETUP-###
hero.say("Start MasterFunction") 

heroPos = hero.pos
coins = hero.findByType("coin")
nueCoins = heroCentered(coins, heroPos)
hist = itemHistogram(nueCoins)
hero.say(hist)

listHist = histListFn(hist)
1 Like

If I recall correctly, the error happens when you try to say an object whose toString method has been overridden by the Python runtime. I believe @rob can provide more details and correct me if Iā€™m wrong.

2 Likes

So, is there anything I can do? Or am I stuck unable to read lists.
Thanks
-Cheers

1 Like

I believe this is a bug in the engine that the developers should fix.

For the time being, you can use this hack (not really valid Python but it works):

hero.say(histList.join(', '))
2 Likes

Thank you! That seems to fix the problem for now. I hope the development team fixes the bug soon.
-Cheers