Heya Everyone!!
I’m working on an entity module and I currently have two classes. A BaseEntity
class and a Starvlud
(Enemy/Entity) subclass. I’m trying to make it so whenever an entity that uses the subclass spawns, I want the module to run.
BaseEntity
--[[SERVICES]]--
local ServerStorage = game:GetService("ServerStorage")
local PathfindingService = game:GetService("PathfindingService")
--[[FOLDERS]]--
local EntityFolder = ServerStorage:WaitForChild("Entities")
local RegularFolder = EntityFolder.Regular
local SpecialFolder = EntityFolder.Special
--[[MODULE]]--
local BaseEntity = {}
BaseEntity.__index = BaseEntity
--//Creating the entity
function BaseEntity:CreateEntity(EntityName)
--//Finding entity
local RequestedEntity = RegularFolder:FindFirstChild(EntityName) if not EntityName then
RequestedEntity = SpecialFolder:FindFirstChild(EntityName) if not EntityName then
warn("CANNOT FIND ENTITY: "..EntityName)
return
end
end
--//Creating entity
local self = setmetatable({}, BaseEntity)
self.Entity = RequestedEntity:Clone()
self.Humanoid = RequestedEntity:FindFirstChildWhichIsA("Humanoid")
self.Entity.Parent = game.Workspace
return self
end
return BaseEntity
Starvlud
--[[SUPERCLASS]]--
local BaseEntity = require(script.Parent)
--[[MODULE]]--
local StarvludModule = setmetatable({}, BaseEntity)
StarvludModule.__index = StarvludModule
function StarvludModule:SetupEntity()
local self = setmetatable(BaseEntity:CreateEntity(), StarvludModule)
return self
end
--//Starvlud will be using a custom "wandering" function.
--//This'll actually make Starvlud try to walk in front of the player.
function StarvludModule:TryAmbush()
--//TBA
end
--//Otherwise, he'll just use the premade functions in BaseEntity
function StarvludModule:TestFunction()
--//TBA
end
return StarvludModule