OOP and metatables - pairs problem
Hello everyone,
I want to use some classes for my addon, but I have a problem with pairs() in methods. A exemple : Code:
ClassTest = {} |
Your metatable is fine, what's not fine is that pairs supplies your iterator for you. You don't set it yourself.
Lua Code:
|
Thanks for the answer.
Quote:
|
Quote:
|
pairs returns the key, value pairs in a table
Code:
self.tab = { |
Quote:
|
Quote:
Code:
-- Class Pokemon -- 'do' is here, I don't understand what I missed. |
local self = {}
Is local to that chunk of code (in this case function) hence doesn't exist in the lower function and has not been passed to it. You would need too: Code:
function CPA_Pokemon_Class:InitFight(table) Code:
self.stat.pv = { I'm not metatable enabled so there is probably a more direct method using it. |
Quote:
PS : The function isn't even called, it's like a syntax error. |
please Show your whole Code. Looks like you never call the New function
|
Quote:
|
Okay, I find out the problem... I let a initialisation on a ipairs... I'm dumb.
Thanks for all, I will post the finale addon when it will be ready. |
Well, of course you're getting syntax errors. You only corrected the iterator in one place. That's not what's giving you the error. You have to correct all the other iterators in your code. It fails while compiling, not while running. Hint: read the line number in your error.
|
Quote:
It compile now :) |
All times are GMT -6. The time now is 05:32 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI