This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
_UndeadMC_'s profile picture

Essentia Refill System

Started by _UndeadMC_, 19 June 2014 - 06:49 AM
_UndeadMC_ #1
Posted 19 June 2014 - 08:49 AM
Please help me, in this code:

full code is here

and i getting error with the 44. line.


function scanJars()
  local myEmptyJars = 0
  local myTotalJars = 0
  local jars = {}
  local jarID = 1
  local aspect
  local aspectCount
  local i, j

  for i,j in ipairs(peripheral.getNames()) do
    if peripheral.getType(j) == "tilejar" then
          base = peripheral.call(j, "getAspects")[1.0]
          aspect = base["name"]
      aspectCount = base["quantity"]

      if (aspectCount > 0) then
        jars[jarID] = {}
        jars[jarID]["aspect"] = aspect
        jars[jarID]["count"] = aspectCount
        jarID = jarID + 1
        myTotalJars = myTotalJars + 1
      elseif (aspectCount == 0) then
        myEmptyJars = myEmptyJars + 1
        myTotalJars = myTotalJars + 1
      end
    end
  end

  emptyJars = myEmptyJars
  totalJars = myTotalJars

  return jars
end

function updateEssentia()
  local myJars
  local myEssentia
  local i, j

  myJars = scanJars()
  myEssentia = essentiaList()

  for i in pairs(myJars) do
    myEssentia[myJars[i]["aspect"]] = myEssentia[myJars[i]["aspect"]] + myJars[i]["count"]
  end

  for i,j in sortEss(myEssentia) do
    if (essentia[i] ~= j) then
      essentia[i] = j
    end
  end
end
Edited by
theoriginalbit #2
Posted 19 June 2014 - 09:30 AM
split into new topic
Bomb Bloke #3
Posted 19 June 2014 - 09:44 AM
and i getting error with the 44. line.

Which line do you mean, exactly? This one?

                myEssentia[myJars[i]["aspect"]] = myEssentia[myJars[i]["aspect"]] + myJars[i]["count"]

What does the error actually state?
theoriginalbit #4
Posted 19 June 2014 - 09:56 AM
line 44 on the pastebin is a comment, so yeah, please provide us more information.