Jump to content

luaNext: first parameter is not a table


Tungstène

Recommended Posts

I'm trying to develop a new cartridge (named cartIloveStrasbourg). On cartridge start and restore events, it scans all the zones and modifies some properties...

 

First, it ran perfectly with the webwigo emulator. This was the code:

function InitZones()
  for k,z in pairs(cartIloveStrasbourg:GetAllOfType('Zone')) do
    if string.sub(z.Name, 1, 3) == "TA " then
      z.Visible = false
      z.Active = false
      function z:OnEnter()
        AddToPassport(self)
      end
    end
  end
end

When I tried it IRL, WhereYouGo crashed with an error. I understood that OpenWIG doesn't implement the GetAllOfType method. I corrected my code with this new one:

function InitZones()
  for k,z in pairs(cartIloveStrasbourg.AllZObjects) do
    if Wherigo.Zone:made(z) then
      if string.sub(z.Name, 1, 3) == "TA " then
        z.Visible = false
        z.Active = false
        function z:OnEnter()
          AddToPassport(self)
        end
      end
    end
  end
end

This code is working both with the emulator (webwigo) and the Android players (WhereYouGo and Wherigeooh).

I asked a friend of mine to test with his iPhone and the cartridge crashes with this error message:

 

Quote

 

LUA Alert

luaNext: first parameter is not a table

 

 

There is nothing else displayed (no line number, nothing).

 

Did I make something wrong? It's hard to test without an iPhone at hand... Any help would be appreciated.

Link to comment

I wrote a test cartridge. My friend tried it with his iPhone. This cartridge just shows the type of the cartridge's property AllZObjects using different ways to access it.

  • cartridge.AllZObjects is not a table but nil.
  • _G["cartridge"]["AllZObjects"] is not a table either but nil too.

I found an old thread on this forum saying that iPhone Wherigo Player wasn't able to use this property but I looked at the code of some open source cartridge known to work with iPhones and they use this property.

 

What could be wrong?

Edited by Tungstène
English is not my native language...
Link to comment

I finally found what's wrong. Despite iOS Wherigo Player telling us AllZObjects is nil, access to this table's members is possible. So, I was investigating in a wrong direction.

 

This code works on iPhone (and on Android):

function InitZones()
  for k,z in ipairs(cartIloveStrasbourg.AllZObjects) do
    if Wherigo.NoCaseEquals(tostring(z), "a Zone instance") then
      if string.sub(z.Name, 1, 3) == "TA " then
        z.Visible = false
        z.Active = false
        function z:OnEnter()
          AddToPassport(self)
        end
      end
    end
  end
end

Do you see what has changed? Call to the "made" method of the Wherigo class seems not to be implemented either in iOS Wherigo Player!

Edited by Tungstène
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...