Would a OOP be useful for making a pet system? If it is, can i have some examples of some methods/properties appropriate for it.
✓ ANSWER ACCEPTED
Would a OOP be useful for making a pet system?
1 answer
✓ Accepted answer
OOP
local pet = {}
pet.__index = pet
function pet.new(name, type) -- Type, could be Cat, Dog, Fish etc
local petObject = setmetatable({}, pet}
petObject.name = name
petObject.type = type
return petObject
end
function pet:GetName()
return self.name
end
function pet:GetType()
return self.type
end
function pet:FollowPlayer(player)
-- Code here
end
return pet
If I'm correct, you could do something along the lines of this.
2 comments
0
and yes, you should definitely use OOP for a pet system :)
0
Nice, ill consider recoding my pet system
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
It would defeinitely, you have main class Pet and other pet classes inherit from it.