?

?

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

?

Post by bobthedinosaur »

{
Last edited by bobthedinosaur on 25 Oct 2009, 06:00, edited 1 time in total.
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: umm what does this mean?

Post 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.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: umm what does this mean?

Post by bobthedinosaur »

!
Last edited by bobthedinosaur on 25 Oct 2009, 06:00, edited 1 time in total.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: umm what does this mean?

Post 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.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: umm what does this mean?

Post by zwzsg »

It means that at the 1055th lines of the file LuaRules/Gadgets/unit_morph.lua the 1st argument of 'snext' is undefined.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: umm what does this mean?

Post by bobthedinosaur »

.
Last edited by bobthedinosaur on 25 Oct 2009, 06:00, edited 1 time in total.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: umm what does this mean?

Post 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.
SeanHeron
Engines Of War Developer
Posts: 614
Joined: 09 Jun 2005, 23:39

Re: umm what does this mean?

Post 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
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: umm what does this mean?

Post 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.
SeanHeron
Engines Of War Developer
Posts: 614
Joined: 09 Jun 2005, 23:39

Re: umm what does this mean?

Post 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!)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: umm what does this mean?

Post 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.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: umm what does this mean?

Post by bobthedinosaur »

.
Last edited by bobthedinosaur on 25 Oct 2009, 05:59, edited 1 time in total.
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: umm what does this mean?

Post 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)
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: umm what does this mean?

Post by bobthedinosaur »

.
Last edited by bobthedinosaur on 25 Oct 2009, 05:59, edited 1 time in total.
SeanHeron
Engines Of War Developer
Posts: 614
Joined: 09 Jun 2005, 23:39

Re: umm what does this mean?

Post 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).
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: umm what does this mean?

Post 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)
SeanHeron
Engines Of War Developer
Posts: 614
Joined: 09 Jun 2005, 23:39

Re: umm what does this mean?

Post 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)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: umm what does this mean?

Post 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.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: umm what does this mean?

Post by Tribulex »

Was a solution ever found, because im having this same @$%&ing problem.
SeanHeron
Engines Of War Developer
Posts: 614
Joined: 09 Jun 2005, 23:39

Re: umm what does this mean?

Post 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!)
Post Reply

Return to “Lua Scripts”