Here's an example of what I'm trying to do:
local table = {
poop = {
poops = 5
},
poopFunction = function()
table.poop.poops = 10
end
}
Here's an example of what I'm trying to do:
local table = {
poop = {
poops = 5
},
poopFunction = function()
table.poop.poops = 10
end
}
Using your example, you just wanna call the function and that will work without errors.
local table = {
poop = {
poops = 5
},
poopFunction = function()
table.poop.poops = 10
end
}
table.poopFunction() -- will run the function
Or you could use metatables, which can access the self keyword.
local table = {
poop = {
poops = 5
}
}
table.__index = table
function table:poopFunction()
self.poop.poops = 10
end
table:poopFunction() -- will run the function
Most basic explanation is, the self keyword refers to the table in which the function is located within.
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
I already know how to do that I want a table to edit itself though
I don't think that's what he wanted. What you are posting makes no sense and your explanation doesn't make sense either. You should've just posted the documentation
That's what it's doing - editing itself. I don't get what you are trying to say.
The question doesn't make sense, you're asking how to edit a value in a table that is inside of a table, which is what he did. Try explaining it a bit better.