#How to pass self as an argument and use its functions

1 messages · Page 1 of 1 (latest)

winter horizon
#

.

#
function Pizza.new()
    local self = setmetatable({}, Pizza)    
    Queue.Add(self)
    
    return self
end

#
local Queue = {}
Queue.__index = Queue

Queue.list = {}
isCooking = false

local foodModules = script.Parent.FoodModules

local function StartNext()
    isCooking = true
    local next = Queue.list[1]
    local foodModule = require(foodModules:FindFirstChild(next))
    next:Make()
end

function Queue.OnCookingFinished()
    if #Queue.list > 0 then
        table.remove(Queue.list, 1)
        StartNext()
    else
        isCooking = false
    end
end

function Queue.Add(instance)
    table.insert(Queue.list, instance)
    if not isCooking then
        StartNext()
    end
end

return Queue
#

so im passing self as an argument to queue.add and idk how to use its :Make function at the StartNext function is that even possible?