Jump to content




window:233: bad argument: double expected, got nil


  • You cannot reply to this topic
3 replies to this topic

#1 TheRockettek

  • Members
  • 547 posts
  • LocationRem is best girl

Posted 02 November 2016 - 09:43 AM

I am looking at my code on why its not working and i am blind X_X

term.clear()
xy,tc,bc = term.setCursorPos(),term.setTextColour(),term.setBackgroundColour()
local cut = function(t,l)
if string.len(t) > l then
  return string.sub(t,1,l)
else
  return t
end
end
local draw = function()
res = {term.getSize()}
paintutils.drawFilledBox(1,1,res[1],res[2],colours.white)
paintutils.drawFilledBox(1,1,res[1],3,colours.cyan)
xy(2,2)
bc(colours.cyan)
if path == "/" then
  tc(colours.lightGrey)
else
  tc(colours.white)
end
term.write("<")
xy(4,2)
tc(colours.white)
term.write(cut(path,res[1]-4))
end
while true do
if not path then path = "/" end
local offset = 0
local y = 4
local fileList = fs.list(path)
draw()
if #fileList > res[2]-3 then
  local len = res[2]-3
else
  local len = #fileList
end
for i=1,len,1 do
  local filePath = fs.combine(path,fileList[i+offset])
  if fs.isDir(filePath) then
   paintutils.drawFilledBox(1,y,1,y,colours.blue)
  elseif fs.isReadOnly(filePath) then
   paintutils.drawFilledBox(1,y,1,y,colours.red)
  else
   paintutils.drawFilledBox(1,y,1,y,colours.yellow)
  end
  xy(3,y)
  tc(colours.grey)
  bc(colours.white)
  term.write(fileList[i+offset])
  y=y+1
end
local e,c,a,b = os.pullEvent()
if e == "mouse_up" then -- click
  if c == 1 then
  -- leftclick
  elseif c == 2 then
   local offset = 0
  elseif c == 3 then
  -- rightclick
  end
elseif e == "mouse_scroll" then -- scroll
  if a == "-1" and offset > 0 then
   local offset = offset - 1
  elseif a == "1" and offset < #fileList then
   local offset = offset + 1
  end
end
end

Edited by TheRockettek, 02 November 2016 - 11:19 AM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 02 November 2016 - 11:11 AM

You should not be calling functions while you attempt to assign them to variables.

Edit: Bomb Bloke is blind today, x is most definitely nil on the second line of your program.

Edited by KingofGamesYami, 02 November 2016 - 11:13 AM.


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 02 November 2016 - 11:11 AM

Line 233 falls inside the setCursorPos function (assuming your CC install is at least somewhat up-to-date), and is checking the x value specifically. Nowhere in the code you've provided would the x value possibly be nil - double check that this is the code you're actually running on your computer, and that this is all of the code involved.

*headdesk* Yami has better eyes than I do.

Edited by Bomb Bloke, 02 November 2016 - 11:13 AM.


#4 TheRockettek

  • Members
  • 547 posts
  • LocationRem is best girl

Posted 02 November 2016 - 11:19 AM

Just needed to change

xy,tc,bc = term.setCursorPos(),term.setTextColour(),term.setBackgroundColour()

into
[/color]
[color=#666600]xy,tc,bc = term.setCursorPos,term.setTextColour,term.setBackgroundColour[/color]
[color=#666600]






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users