--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]] local ____modules = {} local ____moduleCache = {} local ____originalRequire = require local function require(file) if ____moduleCache[file] then return ____moduleCache[file] end if ____modules[file] then ____moduleCache[file] = ____modules[file]() return ____moduleCache[file] else if ____originalRequire then return ____originalRequire(file) else error("module '" .. file .. "' not found") end end end ____modules = { ["index"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]] end, ["classes.Feature"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]] -- Lua Library inline imports function __TS__Class(self) local c = {prototype = {}} c.prototype.__index = c.prototype c.prototype.constructor = c return c end function __TS__ArrayPush(arr, ...) local items = {...} for ____, item in ipairs(items) do arr[#arr + 1] = item end return #arr end function __TS__ArraySplice(list, ...) local len = #list local actualArgumentCount = select("#", ...) local start = select(1, ...) local deleteCount = select(2, ...) local actualStart if start < 0 then actualStart = math.max(len + start, 0) else actualStart = math.min(start, len) end local itemCount = math.max(actualArgumentCount - 2, 0) local actualDeleteCount if actualArgumentCount == 0 then actualDeleteCount = 0 elseif actualArgumentCount == 1 then actualDeleteCount = len - actualStart else actualDeleteCount = math.min( math.max(deleteCount or 0, 0), len - actualStart ) end local out = {} do local k = 0 while k < actualDeleteCount do local from = actualStart + k if list[from + 1] then out[k + 1] = list[from + 1] end k = k + 1 end end if itemCount < actualDeleteCount then do local k = actualStart while k < (len - actualDeleteCount) do local from = k + actualDeleteCount local to = k + itemCount if list[from + 1] then list[to + 1] = list[from + 1] else list[to + 1] = nil end k = k + 1 end end do local k = len while k > ((len - actualDeleteCount) + itemCount) do list[k] = nil k = k - 1 end end elseif itemCount > actualDeleteCount then do local k = len - actualDeleteCount while k > actualStart do local from = (k + actualDeleteCount) - 1 local to = (k + itemCount) - 1 if list[from + 1] then list[to + 1] = list[from + 1] else list[to + 1] = nil end k = k - 1 end end end local j = actualStart for i = 3, actualArgumentCount do list[j + 1] = select(i, ...) j = j + 1 end do local k = #list - 1 while k >= ((len - actualDeleteCount) + itemCount) do list[k + 1] = nil k = k - 1 end end return out end function __TS__ClassExtends(target, base) target.____super = base local staticMetatable = setmetatable({__index = base}, base) setmetatable(target, staticMetatable) local baseMetatable = getmetatable(base) if baseMetatable then if type(baseMetatable.__index) == "function" then staticMetatable.__index = baseMetatable.__index end if type(baseMetatable.__newindex) == "function" then staticMetatable.__newindex = baseMetatable.__newindex end end setmetatable(target.prototype, base.prototype) if type(base.prototype.__index) == "function" then target.prototype.__index = base.prototype.__index end if type(base.prototype.__newindex) == "function" then target.prototype.__newindex = base.prototype.__newindex end if type(base.prototype.__tostring) == "function" then target.prototype.__tostring = base.prototype.__tostring end end local ____exports = {} ____exports.FeatureParent = __TS__Class() local FeatureParent = ____exports.FeatureParent FeatureParent.name = "FeatureParent" function FeatureParent.prototype.____constructor(self, name, parent) self.parentid = 0 self.children = {} self.name = name if parent then self.parent = parent self.parentid = parent.id self.parent:addChild(self) end print( self:type() ) self.feat = menu.add_feature( name, self:type(), self.parentid, function() return self:select() end ) self.id = self.feat.id end function FeatureParent.prototype.type(self) return "parent" end function FeatureParent.prototype.hidden(self) return Boolean(nil, self.feat.hidden) end function FeatureParent.prototype.sethidden(self, val) self.feat.hidden = val end function FeatureParent.prototype.select(self) end function FeatureParent.prototype.addChild(self, feat) do local i = 0 while i < #self.children do if self.children[i + 1]:equals(feat) then return end i = i + 1 end end __TS__ArrayPush(self.children, feat) end function FeatureParent.prototype.removeChild(self, feat) do local i = 0 while i < #self.children do if self.children[i + 1]:equals(feat) then __TS__ArraySplice(self.children, i, 1) end i = i + 1 end end end function FeatureParent.prototype.equals(self, feat) return self.id == feat.id end ____exports.FeatureAction = __TS__Class() local FeatureAction = ____exports.FeatureAction FeatureAction.name = "FeatureAction" __TS__ClassExtends(FeatureAction, ____exports.FeatureParent) function FeatureAction.prototype.____constructor(self, name, parent, handler) FeatureAction.____super.prototype.____constructor(self, name, parent) if handler then self.handler = handler end end function FeatureAction.prototype.type(self) return "action" end function FeatureAction.prototype.select(self) if self.handler then self:handler(self) end end function FeatureAction.prototype.setHandler(self, handler) self.handler = handler end ____exports.FeatureToggle = __TS__Class() local FeatureToggle = ____exports.FeatureToggle FeatureToggle.name = "FeatureToggle" __TS__ClassExtends(FeatureToggle, ____exports.FeatureAction) function FeatureToggle.prototype.____constructor(self, name, parent, defaultvalue, handler) if defaultvalue == nil then defaultvalue = false end FeatureToggle.____super.prototype.____constructor(self, name, parent, handler) self:setvalue(defaultvalue) end function FeatureToggle.prototype.type(self) return "toggle" end function FeatureToggle.prototype.value(self) return self.feat.on end function FeatureToggle.prototype.setvalue(self, val) self.feat.on = val end function FeatureToggle.prototype.toggle(self) self.feat.on = not self.feat.on end ____exports.FeatureNum = __TS__Class() local FeatureNum = ____exports.FeatureNum FeatureNum.name = "FeatureNum" __TS__ClassExtends(FeatureNum, ____exports.FeatureAction) function FeatureNum.prototype.____constructor(self, name, parent, defaultnum, handler) if defaultnum == nil then defaultnum = 0 end FeatureNum.____super.prototype.____constructor(self, name, parent, handler) self:setnum(defaultnum) end function FeatureNum.prototype.type(self) return "action_value_i" end function FeatureNum.prototype.num(self) return self.feat.value_i end function FeatureNum.prototype.setnum(self, val) self.feat.value_i = val end function FeatureNum.prototype.min(self) return self.feat.min_i end function FeatureNum.prototype.setmin(self, val) self.feat.min_i = math.floor(val + 0.5) end function FeatureNum.prototype.max(self) return self.feat.max_i end function FeatureNum.prototype.setmax(self, val) self.feat.max_i = math.floor(val + 0.5) end function FeatureNum.prototype.step(self) return self.feat.mod_i end function FeatureNum.prototype.setstep(self, val) self.feat.mod_i = math.floor(val + 0.5) end ____exports.FeatureNumToggle = __TS__Class() local FeatureNumToggle = ____exports.FeatureNumToggle FeatureNumToggle.name = "FeatureNumToggle" __TS__ClassExtends(FeatureNumToggle, ____exports.FeatureNum) function FeatureNumToggle.prototype.____constructor(self, name, parent, defaultnum, defaultvalue, handler) if defaultnum == nil then defaultnum = 0 end if defaultvalue == nil then defaultvalue = false end FeatureNumToggle.____super.prototype.____constructor(self, name, parent, defaultnum, handler) self:setvalue(defaultvalue) end function FeatureNumToggle.prototype.type(self) return "value_i" end function FeatureNumToggle.prototype.value(self) return self.feat.on end function FeatureNumToggle.prototype.setvalue(self, val) self.feat.on = val end function FeatureNumToggle.prototype.toggle(self) self.feat.on = not self.feat.on end return ____exports end, ["test"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]] -- Lua Library inline imports function __TS__New(target, ...) local instance = setmetatable({}, target.prototype) instance:____constructor(...) return instance end local ____exports = {} local ____Feature = require("classes.Feature") local FeatureAction = ____Feature.FeatureAction local FeatureParent = ____Feature.FeatureParent local fps = 60 local duration = 5 menu.add_feature( "test", "action", 0, function() do local i = 0 while i < (fps * duration) do scriptdraw.draw_rect( v2(0, 0), v2(1, 1), 4294967295 ) system.wait(0) i = i + 1 end end end ) local testParent = __TS__New(FeatureParent, "class") __TS__New( FeatureAction, "testClass", testParent, function(____, f) if f.parent then print( (("parent: " .. f.parent.name) .. "\nid: ") .. tostring(f.parent.id) ) end do local i = 0 while i < (fps * duration) do scriptdraw.draw_rect( v2(0, 0), v2(1, 1), 4294967295 ) system.wait(0) i = i + 1 end end end ) return ____exports end, } return require("test")