Lets say I want to ban an object's method from being used. This requires me to know what method needs to be banned, hence the question.
This isn't a roblox Default object, like Part, but rather a theoretical object held together by a table.
In order to ban a method from it, I'm going to give the object a ban method that takes in the argument of a method and adds it to the ban list. That way it only needs to glimpse at the ban list to see if the method is within it to determine what function can run.
local Object = {}
function Object.new(someName)
name = someName;
bannedList = {}
temp = {}
function temp:Print()
if checkValidity(temp:Print()) then --This won't work, will cause a stack overflow.
print(name);
end
end
function temp:Ban(someMethod)
table.insert(bannedList, someMethod = true) --not quite sure if this is the right dictionary-key reference here
end
function checkValidity(someMethod)
if bannedList[someMethod] ~= nil --if it's there
return false --invalid
else
return true -- valid
end
end
return temp;
end
return Object
--Driver
test1 = Object.new("Bob");
test1:Print();
test1:Ban(test1:Print()); -- Again, will not work
test1:Print(); --Should do nothing
As you can see, I'm trying to make it that some Instance can tell Object not to use its methods. Though I don't know how to refer to them (Is it something like Object:Ban?)
How do I do this reference? Kudos to whoever could make a more efficient method to ban a function as well

3 comments
"This is your fault, and I blame you. I'm not going to fix it, because I'm lazy and it's not my problem." Downvoted because of that. Do not use put-downs on a user.
I'm not trying to put them down, I'm trying to tell them that any problems they come across with technicalities are their fault, and it's not my job nor anyone else's to fix them. I'm sorry I upset you enough to make you downvote a reasonably correct answer.
Okay my insane misconception of table.insert taking arguments that aren't integer values is fixed, but the whole problem was using the function instead of a name in the first place. I just wanted to see how possible this was - I believe I've found another solution to my actual problem I have.