Jump to content
Sign in to follow this  
Followers 2

Function arrays not working on iphone

Recommended Posts

I'm creating a Wherigo using Urwigo.

One of the structures I'm using is an array of 10 functions. It works fine in the emulator, on webwigo, and WhereYouGo on Android. It doesn't work on apple devices. 

The test Lua code is provided below and I've attached output screenshots. In the code, vProgress is a Urwigo variable initialized to "xxxxxxxxxx".

What seems to be happening is that, on an Apple device, the only entry in the function array that can be accessed is the first one. What the player sees are 9 Lua Alerts that say "Don't know how to call '<null>'".

I've tested a simpler array using the same constants. The entries in that array can be accessed just fine so is it a problem with having functions as array entries?

Can anyone give me any insight into why this is happening?

Thank you.


cBench = 4
cBlocks = 7
cCavity = 3
cSquirrels = 2
cGap = 9
cReturn = 1
cRoot = 5
cRoad = 10
cWart = 6
cWeird = 8

CR = [[

function DoTest()
    -- this works on emulator, webwigo, and android. it does not work on iphone
    GetX = {
    [cBench] = function() return tonumber(string.sub(tostring(Player.ObjectLocation.latitude),6,6)) end,
    [cBlocks] = function() return tonumber(string.sub(tostring(Player.ObjectLocation.longitude),6,6)) end,
    [cCavity] = function() return tonumber(string.sub(tostring(Player.ObjectLocation.longitude),7,7))    end,
    [cSquirrels] = function() return tonumber(string.sub(tostring(Player.ObjectLocation.latitude),5,5)) end,
    [cGap] = function() return tonumber(string.sub(tostring(Player.ObjectLocation.latitude),4,4)) end,
    [cReturn] = function() return tonumber(string.sub(tostring(Player.ObjectLocation.latitude),4,4)) end,
    [cRoot] = function() return tonumber(string.sub(tostring(Player.ObjectLocation.longitude),7,7)) end,
    [cRoad] = function() return tonumber(string.sub(tostring(Player.ObjectLocation.longitude),2,2)) end,
    [cWart] = function() return tonumber(string.sub(tostring(Player.ObjectLocation.longitude),5,5)) end,
    [cWeird] = function() return tonumber(string.sub(tostring(Player.ObjectLocation.longitude),7,7)) end
    for i = 1,10 do
        debugstr = debugstr.."i"..i.." "
        x = GetX()
        debugstr = debugstr .. x.. " "
        newStr = string.sub(vProgress,1,i-1)..x..string.sub(vProgress,i+1)
        vProgress = newStr
    -- a check to see if the constants actually have the values I expect them to have
    local Cstring = cBench.." "..cBlocks.." "..cCavity.." ".. cSquirrels.." ".. cGap.." ".. cReturn.." ".. cRoot.." ".. cRoad.." ".. cWart.." ".. cWeird    
    local outputstr = "The constants: "..Cstring..CR..CR
    outputstr = outputstr.."debugstr: "..debugstr..CR..CR
    outputstr = outputstr.."vProgress: "..vProgress
    Wherigo.MessageBox{Text = outputstr}

Ipad screenshot.jpg

Emulator output.jpg

  • Upvote 1

Share this post

Link to post

I have this problem as well in a cartridge and couldn't figure out why it was happening, because I don't own an iPhone...
If it turns out this is the reason, thank you for describing the problem! I'll try using a local variable like

for i = 1,10 do
local f = GetX[i]

and see if that helps!


Well, unfortunately my changes didn't only not fix it, but apparently caused an infinite loop with the


Don't know how to call '<null>'

messages... I'm confused...

Edited by JakeDot

Share this post

Link to post

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now
Sign in to follow this  
Followers 2