1

我正在使用的程序叫做Oxidizer,一个分形 flam3编辑器。基本上,为了使这些美丽的数字艺术作品动起来,我使用.lua脚本。

我正在使用的一个脚本algorhythm.lua调用其他脚本来运行。一个是控制脚本,cs_temp.lua另一个是utils.lua. 这是我得到错误的地方。

显示为错误的特定行是1399,即以下代码中的第二行。

function alignx(g1,g2)
   local x1,x2 = #g1.xforms,#g2.xforms
 -- Align xforms for final-x, pad if necessary
local fx1,fx2 = 0,0

for x=1,x1 do
      if g1.xforms[x].is_finalxform == "Y" then fx1 = x end
   end
   for x=1,x2 do
      if g2.xforms[x].is_finalxform == "Y" then fx2 = x end
   end
   if fx1>0 or fx2>0 then

  -- case 1: both have finalx - reorder g2

  if fx1>0 and fx2>0 and fx1~=fx2 then
 print('case 1')
 if fx1>x2 then              -- pad g2 with sufficient xforms
    for i=1,math.abs(fx1-x2) do 
       table.insert(g2.xforms,newx())
       print("adding xform to genome 2") 
    end
    x2 = #g2.xforms
 end
 x2ind = agen(x2,1,x2)
 x2ind[fx2] = fx1
 x2ind[fx1] = fx2
 xforms2 = ordx(g2.xforms,x2ind)
 g2.xforms = xforms2
  end

  -- case 2: g1 has finalx but not g2 - xpad and reorder g2
  if fx1>0 and fx2==0 then
 print('case 2')             -- pad g2 with final xform
 local xtmp = newx(1)
 xtmp.is_finalxform = 'Y'
 xtmp.symmetry = 1
 table.insert(g2.xforms,clone_genome(xtmp))
 print("adding final xform to genome 2") 
 x2 = #g2.xforms
 fx2 = x2
 if fx1>x2 then              -- pad g2 with sufficient xforms
    for i=1,math.abs(fx1-x2) do 
       table.insert(g2.xforms,newx())
       print("adding xform to genome 2") 
    end
    x2 = #g2.xforms
 end
 x2ind = agen(x2,1,x2)
 x2ind[fx2] = fx1
 x2ind[fx1] = fx2
 xforms2 = ordx(g2.xforms,x2ind)
 g2.xforms = xforms2
  end

  -- case 3: g2 has finalx but not g1 - xpad g1 and reorder g2
  if fx1==0 and fx2>0 then
 print('case 3')
 local xtmp = newx(1)
 xtmp.is_finalxform = 'Y'
 xtmp.symmetry = 1
 table.insert(g1.xforms,clone_genome(xtmp))
 print("adding final xform to genome 1") 
 x1 = #g1.xforms
 fx1 = x1
 if fx1>x2 then              -- pad g2 with sufficient xforms
    for i=1,math.abs(fx1-x2) do 
       table.insert(g2.xforms,newx())
       print("adding xform to genome 2") 
    end
    x2 = #g2.xforms
 end
 x2ind = agen(x2,1,x2)
 x2ind[fx2] = fx1
 x2ind[fx1] = fx2
 xforms2 = ordx(g2.xforms,x2ind)
 g2.xforms = xforms2
  end
 end
end

我知道要筛选的内容很多,但我想尽可能具体。

4

1 回答 1

3

根据您的问题(仍不清楚),以下行是有问题的行:

local x1,x2 = #g1.xforms,#g2.xforms

Lua程序中出现错误尝试索引,因为您需要将其初始化为表,这再次要求成为表。g2.xformsg2

检查您的整个代码并跟踪您定义g2为函数的任何地方,因为您的程序将其解释为函数变量而不是表。

于 2013-01-16T01:23:05.687 回答