51 posts
Posted 26 April 2014 - 08:49 PM
local function redraw()
renderOrder = {}
assert( type( renderOrder ) ~= "table", "renderOrder's type is not table" )
end
redraw()
What am I missing? Is it a bug in ComputerCraft or a bug in my program? Please help?!?
When I use renderOrder[ 1 ] == {} it errors aswell.
1140 posts
Location
Kaunas, Lithuania
Posted 26 April 2014 - 08:58 PM
This is how assert works: it takes a first parameter as a condition (condition can be anything) and checks wether it is false or nil. If it is then it errors using the message that was set as the second parameter. If the condition was not equal to false or nil then it returns all parameters passed to assert function.
Note: '~=' in Lua means 'not equal'.
I hope that will help you to find your problem :)/>.
51 posts
Posted 26 April 2014 - 09:58 PM
This is how assert works: it takes a first parameter as a condition (condition can be anything) and checks wether it is false or nil. If it is then it errors using the message that was set as the second parameter. If the condition was not equal to false or nil then it returns all parameters passed to assert function.
Note: '~=' in Lua means 'not equal'.
I hope that will help you to find your problem :)/>.
Thanks, I used ~= when debugging after using == when testing, I guess. At least, when I rebooted, everything else worked fine ( renderOrder[1] = {} didnt work before the reboot, it gave type( renderOrder[1] ) == "nil" )
62 posts
Posted 26 April 2014 - 10:06 PM
YoYoYonny, Your first should of worked correctly.
Assuming you are checking not equal to "table"
Edited on 26 April 2014 - 08:06 PM
51 posts
Posted 27 April 2014 - 01:08 AM
- Snip -
The first problem was I used ~= instead of ==.
The second problem was I used local renderOrder and global renderOrder.
When I tried == with a global renderOrder everything worked fine.
But when I tried ~= with a local renderOrder it would error (It couldn't find renderOrder as a table), and I didn't know how (Its always wierd when you get an unexpected error while debugging).
62 posts
Posted 27 April 2014 - 03:12 AM
Oh I just realized that. I'm blind