尝试对本地变量'g2'(一个函数值)进行索引。
2017-10-24 10:52:23
收藏:0
阅读:140
评论:1
我使用的程序叫做 Oxidizer,是一款 fractal flam3 编辑器。基本上,为了制作这些美丽的数字艺术作品,我使用了 .lua 脚本。
我正在使用的一个脚本叫做 algorhythm.lua,它调用其他脚本以使之正常运行。其中一个脚本是控制脚本 cs_temp.lua,另一个是 utils.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
我知道这很多,但我尽可能具体。
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
根据你的问题(仍不清楚),以下一行是有问题的:
local x1,x2 = #g1.xforms,#g2.xforms在 Lua 程序中,错误尝试对索引进行发生是因为你的
g2.xforms需要初始化为一个表格,这又需要g2为一个表格。检查你的整个代码,并追踪一下是否在任何地方定义了
g2为函数,因为你的程序将其解释为函数变量而不是表格。