Page 1 of 2

?

Posted: 21 Aug 2009, 09:44
by bobthedinosaur
{

Re: umm what does this mean?

Posted: 21 Aug 2009, 10:02
by Niobium
Gadget
unit_morph.lua
Line 1055
Function 'snext'
First argument
Argument is 'nil', i.e. no value set, the function expected/required a table.

Re: umm what does this mean?

Posted: 21 Aug 2009, 17:27
by bobthedinosaur
!

Re: umm what does this mean?

Posted: 21 Aug 2009, 17:28
by lurker
Hint, it might help if you show us what the code is doing at the time it breaks, maybe pastebins of the gadget and config? Right now we don't even know the name of the should-be-a-table-but-isn't, let alone what it's doing with it.

Re: umm what does this mean?

Posted: 21 Aug 2009, 19:16
by zwzsg
It means that at the 1055th lines of the file LuaRules/Gadgets/unit_morph.lua the 1st argument of 'snext' is undefined.

Re: umm what does this mean?

Posted: 22 Aug 2009, 00:49
by bobthedinosaur
.

Re: umm what does this mean?

Posted: 22 Aug 2009, 00:59
by zwzsg
I wonder who is that someone, and why both of you fails at reading, because the error message says that snext is actually defined.

Re: umm what does this mean?

Posted: 22 Aug 2009, 01:35
by SeanHeron
That someone was me, and my choice of words was poor - yes snext is defined ( as snext) in the morph lua, what I was trying to get at is where is there actually the value set...
- I just realised though, that you're very right and I had been misreading - I had thought/assumed snext to be a variable... (and hadn't changed that assumption even when glancing over the code...).
So my bad for leading Bob on the wrong track of thinking.

Edit: as I don't think I'm going to be able to help any further (and don't want to do an even greater disservice), the culprit is "if snext(SYNCED.morphUnits) then" in line 6 of below:

Code: Select all

function gadget:Update()
  local frame = spGetGameFrame()
  	Spring.Echo("Every so often")
  if (frame>oldFrame) then
    oldFrame = frame
    if snext(SYNCED.morphUnits) then
      local useLuaUI_ = Script.LuaUI('MorphUpdate')
      if (useLuaUI_~=useLuaUI) then --//Update Callins on change
        drawProgress = not Script.LuaUI('MorphDrawProgress')
        useLuaUI     = useLuaUI_
      end

      if (useLuaUI) then
        local morphTable = {}
        local readTeam, spec, specFullView = nil,GetSpectatingState()
        if (specFullView)
          then readTeam = Script.ALL_ACCESS_TEAM
          else readTeam = GetLocalTeamID() end
        CallAsTeam({ ['read'] = readTeam }, function()
          for unitID, morphData in spairs(SYNCED.morphUnits) do
            if (unitID and morphData)and(IsUnitVisible(unitID)) then
              morphTable[unitID] = {progress=morphData.progress, into=morphData.def.into}
            end
          end
        end)
        Script.LuaUI.MorphUpdate(morphTable)
      end

    end
  end
end

Re: umm what does this mean?

Posted: 22 Aug 2009, 02:02
by lurker
Good, we're getting somewhere.
SYNCED.morphUnits is nil, when it's expected to be a table. That means that in the synced part of the gadget it's not setting up morphUnits.

Re: umm what does this mean?

Posted: 22 Aug 2009, 02:41
by SeanHeron
Okay, I still have absolutely no idea what's going wrong, but I can say how it can be fixed :P.

I pasted the entire set of .lua files in the Spring 1944 LuaRules directory (not anything from the folders) into the folder Bob is using (replacing the main and draw that were in there), and now it works fine (at least for morphing into just one unit)!
I realise that is very much the sledgehammer method, but I like getting things to work first, and then looking into what exactly is wrong :P.
(Seems my feeling in where the error is wasn't too wrong after all - I guess I should work on expressing myself though!)

Re: umm what does this mean?

Posted: 22 Aug 2009, 03:11
by Argh
Just a guess, but snext is probably a table of morphable Units that has some CA-specific junk in it, like a lot of their code does- they don't really write with portability in mind.

Your probably hitting a nil there, because it can't find a given UnitDef, or something silly like that. I'd check the difference between the two implementations where it refers to that variable.

Re: umm what does this mean?

Posted: 22 Aug 2009, 04:22
by bobthedinosaur
.

Re: umm what does this mean?

Posted: 22 Aug 2009, 04:27
by Niobium
Replace

"if snext(SYNCED.morphUnits) then"

With

"if SYNCED.morphUnits and snext(SYNCED.morphUnits) then"

And you are done. (The replacement won't call snext() if morphUnits is nil, and won't enter 'if' block)

Re: umm what does this mean?

Posted: 22 Aug 2009, 05:28
by bobthedinosaur
.

Re: umm what does this mean?

Posted: 22 Aug 2009, 10:35
by SeanHeron
Argh wrote:Just a guess, but snext is probably a table [..].
Your probably hitting a nil there, because it can't find a given UnitDef, or something silly like that. I'd check the difference between the two implementations where it refers to that variable.
lurker wrote:Good, we're getting somewhere. SYNCED.morphUnits is nil, when it's expected to be a table. [..]
I guess I had made the same error of thinking as you Argh, and did have it spelt out before me just as you (if not quite as explisitly) - but that is just obviously wrong.
Do you realise that posts like that are more detrimental than helpful?

Niobium, you're change stops the error occuring, but doesn't fix the underlying problem - which is, as Lurker had pointed out, that SYNCED.morphUnits is nil (when it shouldn't be, as the Gadget is non functional otherwise - I've tested).
But like I said before, this is fixed if a full set of LuaRules luafiles is included in the LuaRules directory (there was only a main.lua and draw.lua lua in there before, both just referring to gadget.lua).

If I can't find anything on it, I'm going to start a thread asking which of these files are needed when, and how things work if they're you have springcontent.sdz set up as a dependency - as that seems to be the problem, and I assume it to be a recurring one for people that don't know their way around the Lua that well (ie me :P).

Re: umm what does this mean?

Posted: 22 Aug 2009, 11:53
by Niobium
SeanHeron wrote:Niobium, you're change stops the error occuring, but doesn't fix the underlying problem - which is, as Lurker had pointed out, that SYNCED.morphUnits is nil (when it shouldn't be, as the Gadget is non functional otherwise - I've tested).
But like I said before, this is fixed if a full set of LuaRules luafiles is included in the LuaRules directory (there was only a main.lua and draw.lua lua in there before, both just referring to gadget.lua).

If I can't find anything on it, I'm going to start a thread asking which of these files are needed when, and how things work if they're you have springcontent.sdz set up as a dependency - as that seems to be the problem, and I assume it to be a recurring one for people that don't know their way around the Lua that well (ie me :P).
Search all the files for 'morphUnits'. morphUnits is probably initialized to nil, rather than an empty table ('morphUnits = {}'), that or somewhere it is being set to nil (Unlikely).

Also using 'morphUnits' when it hasn't been defined anywhere, would result in nil (i.e. you might need to have the file that contains its definition, or define it in unit_morph)

Re: umm what does this mean?

Posted: 22 Aug 2009, 11:58
by SeanHeron
No, my guesstimate is that the file in which the method "SYNCED.morphUnits" is expressed or defined was not actually included into the VFS with the set of Bob was using in LuaRules - check out this thread for a better description of what I see as the problem (it's the one I announced to make above)

Re: umm what does this mean?

Posted: 22 Aug 2009, 12:15
by Argh
SYNCED.MorphUnits is a global variable being set up for UI display purposes, probably. It's not something that you need in order to perform a morph.

TBH, I have no idea, I was just guessing. I did morphing with totally different methods in P.U.R.E.

Re: umm what does this mean?

Posted: 16 Oct 2009, 22:58
by Tribulex
Was a solution ever found, because im having this same @$%&ing problem.

Re: umm what does this mean?

Posted: 25 Oct 2009, 22:14
by SeanHeron
Hey d_b, I'd not been round here recently, so I didn't see your post - sorry.

I did find a "solution" that worked for Bob/Blood and Steel. See below. I realise that may not be the easiest to follow, I might be able to clarify if you have a question.
SeanHeron wrote:Okay, I still have absolutely no idea what's going wrong, but I can say how it can be fixed :P.

I pasted the entire set of .lua files in the Spring 1944 LuaRules directory (not anything from the folders) into the folder Bob is using (replacing the main and draw that were in there), and now it works fine (at least for morphing into just one unit)!
I realise that is very much the sledgehammer method, but I like getting things to work first, and then looking into what exactly is wrong :P.
(Seems my feeling in where the error is wasn't too wrong after all - I guess I should work on expressing myself though!)