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

CC-Chess error

Started by Turtle, 25 March 2012 - 05:01 PM
Turtle #1
Posted 25 March 2012 - 07:01 PM
The CC-Chess team has ran into an error we can't fix

The error:
cc-chess:475: index expected, got nil

The code : (its over 800 lines , don't expect a code tag)
http://pastebin.com/9GDUy1qy

do NOT come with dumb answers , or incomplete answers.

We need to know where the index is missing , not that it is missing.

it happens after line 585 has ben ran but before line 596
Alex_ #2
Posted 25 March 2012 - 08:28 PM
:/ damnn thats a lot of code
Wolvan #3
Posted 25 March 2012 - 09:55 PM
what is that self API?
Turtle #4
Posted 26 March 2012 - 07:49 PM
what is that self API?
Its the Lua class system , google "Lua users wiki Classes"
Advert #5
Posted 26 March 2012 - 10:28 PM
what is that self API?
Its the Lua class system , google "Lua users wiki Classes"

Lua has no class system, though you can implement something similar, if you desire.

It's basically just some syntax sugar:



local tbl = {}

function tbl:stuff() ->
function tbl.stuff(self)
tbl:stuff() ->
tbl.stuff(tbl)

Which allows you to do neat stuff with metamethods.
Turtle #6
Posted 27 March 2012 - 05:27 PM
what is that self API?
Its the Lua class system , google "Lua users wiki Classes"

Lua has no class system, though you can implement something similar, if you desire.

It's basically just some syntax sugar:



local tbl = {}

function tbl:stuff() ->
function tbl.stuff(self)
tbl:stuff() ->
tbl.stuff(tbl)

Which allows you to do neat stuff with metamethods.
Lua classes are with metamethods indeed lol , check this page for info on it

http://lua-users.org/wiki/SimpleLuaClasses
Ian-Moone #7
Posted 27 March 2012 - 05:31 PM
no matter where you are or what your on someone always makes a chess game
Wolvan #8
Posted 27 March 2012 - 08:16 PM
no matter where you are or what your on someone always makes a chess game
First: Chess rules!
Second: Maybe that self API isn't implemented in the CC Lua Interpreter
Advert #9
Posted 27 March 2012 - 08:22 PM
no matter where you are or what your on someone always makes a chess game
First: Chess rules!
Second: Maybe that self API isn't implemented in the CC Lua Interpreter

It's not an API, it's just sugar:


local cat = {}

function cat:new(...)
 local o = {}
 self.__index = self
 setmetatable(o, self)
 return o:__construct(...)
end

function cat:__construct(name)
 self.name = name
 return self
end

function cat:meow()
 print(self.name, " meows!")
end


local Felix = cat:new("Felix")
local Sofia = cat:new("Sofia")

Felix:meow()
Sofia:meow()

Output:


Felix meows!
Sofia meows!
Wolvan #10
Posted 27 March 2012 - 08:38 PM
oh ok sry
Hawk777 #11
Posted 01 April 2012 - 06:41 AM
Line 468 reads:


self.cells[y] = nil

It should read:


self.cells[x][y] = nil