You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Define base class (basically a metatable for our cars)
---@aliasCargpm.std.Car <-- alias Car, so it is easier for us to reference it in params and etc.---@classgpm.std.Car:gpm.std.Object <-- donotforgettoinheritfromgpm.std.Object---@field__classgpm.std.CarClasslocalCar=std.class.base("Car")
---@protected <-- do not forget to add protected so __init won't be shownfunctionCar:__init()
self.speed=0self.color=Color(255, 255, 255)
end
2. Define a class, which will be used to create a Car
---@aliasTruckgpm.std.Truck---@classgpm.std.Truck:gpm.std.Car---@field__classgpm.std.TruckClass---@field__parentgpm.std.CarClass <-- now we need to define the parent, so LuaLS can know how to access our parentlocalTruck=std.class.base("Truck", std.Car)
---@classgpm.std.TruckClass:gpm.std.Truck---@field__basegpm.std.Truck---@overloadfun(): TrucklocalTruckClass=std.class.create(Truck)
std.Truck=TruckClass