需要重新定义对象的帮助

目标是将特殊类型的文件加载到内存中,然后将其所有数据分配给一个名为spec[]的数组中的对象。所有 reassigned 到那里的东西。问题是,由于某种原因,我的对象标识代码没有起作用。Special.type 是指文件类型,定义在我的文件中,但它显示异常,说special是一个nil值。Special = {type = 0} 并且特殊的函数确实存在,所以我不知道它在说什么。下面是代码。

function specload(file)
   if (spec==16) then return -1 end
   local spehand=0
   local specdata=0
   checkArg(1, drv, "string")
   local tmp="/special/" .. file
   if (filesystem.exists(tmp)==true) then
    spechand=filesystem.open(tmp)
    tmp=""
    repeat
     specdata=filesystem.read(spechand, math.huge)
     tmp = tmp .. (specdata or "")
    until not specdata
    read = load(tmp)
    read()
    tmp=0
    if not special.type then
      while true do
       if(spec[tmp]==0) then
          spec[tmp]=special
          special=nil
         else
          tmp=tmp+1
        end
       end
     end
   end
 end

从这里,你可以想出问题,还是我需要带更多的数据?

原文链接 https://stackoverflow.com/questions/69369041

点赞