Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Would a OOP be useful for making a pet system?

Asked by 3 years ago
Edited 3 years ago

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.

0
It would defeinitely, you have main class Pet and other pet classes inherit from it. imKirda 4491 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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.

0
and yes, you should definitely use OOP for a pet system :) BosOfroblox 40 — 3y
0
Nice, ill consider recoding my pet system MikkelCircled 42 — 3y
Ad

Answer this question