Hey again. So I wanted to make some feature that allows you to annotate functions, but I have no idea on how to do this. Basically, I am using a modified class module made by someone, and I want to add a way to annotate functions. Here is some example code of how the class module works:
local Class = require(game.ReplicatedStorage.Class)
local Vehicle = Class {
constructor = function(self, maxfuel)
self.Fuel = 100;
self.MaxFuel = maxfuel;
end,
GetFuelLeft = function(self)
return self.Fuel
end,
}
local Car = Class(Vehicle) {
constructor = function(self, maxfuel, brand)
self.super(self, maxfuel);
self.Brand = brand;
end,
}
local Jeep = Car.new(250, "Jeep")
print(Jeep:GetFuelLeft()) --Would print "250".
However, I want to add a way to annotate table entries/functions, so you could do something like this in theory:
local Class = require(game.ReplicatedStorage.Class)
local Vehicle = Class {
constructor = function(self, maxfuel)
self.Fuel = 100;
self.MaxFuel = maxfuel;
end,
@FuelLimiter(max = 100) --Obviously I know you cant do this, but this is just an example of what I wanted to show.
GetFuelLeft = function(self)
return self.Fuel
end,
}
local Car = Class(Vehicle) {
constructor = function(self, maxfuel, brand)
self.super(self, maxfuel);
self.Brand = brand;
end,
}
local Jeep = Car.new(250, "Jeep")
print(Jeep:GetFuelLeft()) --Would print "100" because the theoretical "@FuelLimiter" annotation would do math.clamp to clamp it between 0 and 100.