?
Moderator: Moderators
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: umm what does this mean?
Gadget
unit_morph.lua
Line 1055
Function 'snext'
First argument
Argument is 'nil', i.e. no value set, the function expected/required a table.
unit_morph.lua
Line 1055
Function 'snext'
First argument
Argument is 'nil', i.e. no value set, the function expected/required a table.
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: umm what does this mean?
!
Last edited by bobthedinosaur on 25 Oct 2009, 06:00, edited 1 time in total.
Re: umm what does this mean?
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?
It means that at the 1055th lines of the file LuaRules/Gadgets/unit_morph.lua the 1st argument of 'snext' is undefined.
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: umm what does this mean?
.
Last edited by bobthedinosaur on 25 Oct 2009, 06:00, edited 1 time in total.
Re: umm what does this mean?
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?
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:
- 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?
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.
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?
Okay, I still have absolutely no idea what's going wrong, but I can say how it can be fixed
.
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
.
(Seems my feeling in where the error is wasn't too wrong after all - I guess I should work on expressing myself though!)

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

(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?
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.
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.
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: umm what does this mean?
.
Last edited by bobthedinosaur on 25 Oct 2009, 05:59, edited 1 time in total.
Re: umm what does this mean?
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)
"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)
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: umm what does this mean?
.
Last edited by bobthedinosaur on 25 Oct 2009, 05:59, edited 1 time in total.
Re: umm what does this mean?
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.
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.lurker wrote:Good, we're getting somewhere. SYNCED.morphUnits is nil, when it's expected to be a table. [..]
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

Re: umm what does this mean?
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).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).
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?
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?
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.
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?
Was a solution ever found, because im having this same @$%&ing problem.
Re: umm what does this mean?
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.
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.
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.
(Seems my feeling in where the error is wasn't too wrong after all - I guess I should work on expressing myself though!)