9_cVv

_tolua

Jun 8th, 2021 (edited)
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.73 KB | None | 0 0
  1. local _tolua = {}
  2.  
  3. _tolua.properties = {
  4.     ScreenGui = {
  5.         --data
  6.         'DisplayOrder',
  7.         'Enabled',
  8.         'IgnoreGuiInset',
  9.         'Name',
  10.         'Parent',
  11.         'ResetOnSpawn',
  12.         'ZIndexBehavior',
  13.         --behavior
  14.         'Archivable',
  15.         --Localiztation
  16.         'AutoLocalize',
  17.         'RootLocalizationTable'
  18.     },
  19.     TextButton = {
  20.         --data
  21.         'Active',
  22.         'AnchorPoint',
  23.         'AutoButtonColor',
  24.         'AutomaticSize',
  25.         'BackgroundColor3',
  26.         'BackgroundTransparency',
  27.         'BorderColor3',
  28.         'BorderMode',
  29.         'BorderSizePixel',
  30.         'LayoutOrder',
  31.         'Modal',
  32.         'Name',
  33.         'Parent',
  34.         'Position',
  35.         'Rotation',
  36.         'Selectable',
  37.         'Selected',
  38.         'Size',
  39.         'SizeConstraint',
  40.         'Style',
  41.         'Visible',
  42.         'ZIndex',
  43.         --behavior
  44.         'Archivable',
  45.         'ClipsDescendants',
  46.         'NextSelectionDown',
  47.         'NextSelectionLeft',
  48.         'NextSelectionRight',
  49.         'NextSelectionUp',
  50.         --text
  51.         'Font',
  52.         'LineHeight',
  53.         'MaxVisibleGraphemes',
  54.         'RichText',
  55.         'Text',
  56.         'TextColor3',
  57.         'TextScaled',
  58.         'TextSize',
  59.         'TextStrokeColor3',
  60.         'TextStrokeTransparency',
  61.         'TextTransparency',
  62.         'TextTruncate',
  63.         'TextWrapped',
  64.         'TextXAlignment',
  65.         'TextYAlignment',
  66.         --localization
  67.         'AutoLocalize',
  68.         'RootLocalizationTable'
  69.     },
  70.     TextLabel = {
  71.         --data
  72.         'Active',
  73.         'AnchorPoint',
  74.         'AutomaticSize',
  75.         'BackgroundColor3',
  76.         'BackgroundTransparency',
  77.         'BorderColor3',
  78.         'BorderMode',
  79.         'BorderSizePixel',
  80.         'LayoutOrder',
  81.         'Name',
  82.         'Parent',
  83.         'Position',
  84.         'Rotation',
  85.         'Selectable',
  86.         'Size',
  87.         'SizeConstraint',
  88.         'Visible',
  89.         'ZIndex',
  90.         --behavior
  91.         'Archivable',
  92.         'ClipsDescendants',
  93.         'NextSelectionDown',
  94.         'NextSelectionLeft',
  95.         'NextSelectionRight',
  96.         'NextSelectionUp',
  97.         --text
  98.         'Font',
  99.         'LineHeight',
  100.         'MaxVisibleGraphemes',
  101.         'RichText',
  102.         'Text',
  103.         'TextColor3',
  104.         'TextScaled',
  105.         'TextSize',
  106.         'TextStrokeColor3',
  107.         'TextStrokeTransparency',
  108.         'TextTransparency',
  109.         'TextTruncate',
  110.         'TextWrapped',
  111.         'TextXAlignment',
  112.         'TextYAlignment',
  113.         --localization
  114.         'AutoLocalize',
  115.         'RootLocalizationTable'
  116.     },
  117.     TextBox = {
  118.         --data
  119.         'Active',
  120.         'AnchorPoint',
  121.         'AutomaticSize',
  122.         'BackgroundColor3',
  123.         'BackgroundTransparency',
  124.         'BorderColor3',
  125.         'BorderMode',
  126.         'BorderSizePixel',
  127.         'ClearTextOnFocus',
  128.         'LayoutOrder',
  129.         'MultiLine',
  130.         'Name',
  131.         'Parent',
  132.         'Position',
  133.         'Rotation',
  134.         'Selectable',
  135.         'SelectionStart',
  136.         'ShowNativeInput',
  137.         'Size',
  138.         'SizeConstraint',
  139.         'Visible',
  140.         'ZIndex',
  141.         --behavior
  142.         'Archivable',
  143.         'ClipsDescendants',
  144.         'NextSelectionDown',
  145.         'NextSelectionLeft',
  146.         'NextSelectionRight',
  147.         'NextSelectionUp',
  148.         --text
  149.         'Font',
  150.         'LineHeight',
  151.         'MaxVisibleGraphemes',
  152.         'PlaceholderColor3',
  153.         'PlaceholderText',
  154.         'RichText',
  155.         'Text',
  156.         'TextColor3',
  157.         'TextScaled',
  158.         'TextSize',
  159.         'TextStrokeColor3',
  160.         'TextStrokeTransparency',
  161.         'TextTransparency',
  162.         'TextTruncate',
  163.         'TextWrapped',
  164.         'TextXAlignment',
  165.         'TextYAlignment',
  166.         --localization
  167.         'AutoLocalize',
  168.         'RootLocalizationTable'
  169.     },
  170.     ImageLabel = {
  171.         --data
  172.         'Active',
  173.         'AnchorPoint',
  174.         'AutomaticSize',
  175.         'BackgroundColor3',
  176.         'BackgroundTransparency',
  177.         'BorderColor3',
  178.         'BorderMode',
  179.         'BorderSizePixel',
  180.         'LayoutOrder',
  181.         'Name',
  182.         'Parent',
  183.         'Position',
  184.         'Rotation',
  185.         'Selectable',
  186.         'Size',
  187.         'SizeConstraint',
  188.         'Visible',
  189.         'ZIndex',
  190.         --behavior
  191.         'Archivable',
  192.         'ClipsDescendants',
  193.         'NextSelectionDown',
  194.         'NextSelectionLeft',
  195.         'NextSelectionRight',
  196.         'NextSelectionUp',
  197.         --Image
  198.         'Image',
  199.         'ImageColor3',
  200.         'ImageRectOffset',
  201.         'ImageRectSize',
  202.         'ImageTransparency',
  203.         'ScaleType',
  204.         'SliceScale',
  205.         --localization
  206.         'AutoLocalize',
  207.         'RootLocalizationTable'
  208.     },
  209.     ImageButton = {
  210.         --data
  211.         'Active',
  212.         'AnchorPoint',
  213.         'AutoButtonColor',
  214.         'AutomaticSize',
  215.         'BackgroundColor3',
  216.         'BackgroundTransparency',
  217.         'BorderColor3',
  218.         'BorderMode',
  219.         'BorderSizePixel',
  220.         'LayoutOrder',
  221.         'Modal',
  222.         'Name',
  223.         'Parent',
  224.         'Position',
  225.         'Rotation',
  226.         'Selectable',
  227.         'Selected',
  228.         'Size',
  229.         'SizeConstraint',
  230.         'Style',
  231.         'Visible',
  232.         'ZIndex',
  233.         --behavior
  234.         'Archivable',
  235.         'ClipsDescendants',
  236.         'NextSelectionDown',
  237.         'NextSelectionLeft',
  238.         'NextSelectionRight',
  239.         'NextSelectionUp',
  240.         --Image
  241.         'HoverImage',
  242.         'Image',
  243.         'ImageColor3',
  244.         'ImageRectOffset',
  245.         'ImageRectSize',
  246.         'ImageTransparency',
  247.         'ScaleType',
  248.         'SliceScale',
  249.         --localization
  250.         'AutoLocalize',
  251.         'RootLocalizationTable'
  252.     },
  253.     Frame = {
  254.         --data
  255.         'Active',
  256.         'AnchorPoint',
  257.         'AutomaticSize',
  258.         'BackgroundColor3',
  259.         'BackgroundTransparency',
  260.         'BorderColor3',
  261.         'BorderMode',
  262.         'BorderSizePixel',
  263.         'LayoutOrder',
  264.         'Name',
  265.         'Parent',
  266.         'Position',
  267.         'Rotation',
  268.         'Selectable',
  269.         'Size',
  270.         'SizeConstraint',
  271.         'Style',
  272.         'Visible',
  273.         'ZIndex',
  274.         --behavior
  275.         'Archivable',
  276.         'ClipsDescendants',
  277.         'NextSelectionDown',
  278.         'NextSelectionLeft',
  279.         'NextSelectionRight',
  280.         'NextSelectionUp',
  281.         --localization
  282.         'AutoLocalize',
  283.         'RootLocalizationTable'
  284.     },
  285.     ScrollingFrame = {
  286.         --data
  287.         'Active',
  288.         'AnchorPoint',
  289.         'AutomaticSize',
  290.         'BackgroundColor3',
  291.         'BackgroundTransparency',
  292.         'BorderColor3',
  293.         'BorderMode',
  294.         'BorderSizePixel',
  295.         'LayoutOrder',
  296.         'Name',
  297.         'Parent',
  298.         'Position',
  299.         'Rotation',
  300.         'Selectable',
  301.         'Size',
  302.         'SizeConstraint',
  303.         'Visible',
  304.         'ZIndex',
  305.         --behavior
  306.         'Archivable',
  307.         'ClipsDescendants',
  308.         'NextSelectionDown',
  309.         'NextSelectionLeft',
  310.         'NextSelectionRight',
  311.         'NextSelectionUp',
  312.         --scrolling
  313.         'AutomaticCanvasSize',
  314.         'BottomImage',
  315.         'CanvasPosition',
  316.         'CanvasSize',
  317.         'ElasticBehavior',
  318.         'HorizontalScrollBarInset',
  319.         'MidImage',
  320.         'ScrollBarImageColor3',
  321.         'ScrollBarImageTransparency',
  322.         'ScrollBarThickness',
  323.         'ScrollingDirection',
  324.         'ScrollingEnabled',
  325.         'TopImage',
  326.         'VerticalScrollBarInset',
  327.         'VerticalScrollBarPosition',
  328.         --localization
  329.         'AutoLocalize',
  330.         'RootLocalizationTable'
  331.     },
  332.     LocalScript = {
  333.         --data
  334.         'Name',
  335.         'Parent',
  336.         --behavior
  337.         'Archivable',
  338.         'Disabled'
  339.     },
  340.     UIGradient = {
  341.         --appearance
  342.         'Color',
  343.         'Enabled',
  344.         'Offset',
  345.         'Rotation',
  346.         'Transparency',
  347.         --data
  348.         'Name',
  349.         'Parent',
  350.         --behavior
  351.         'Archivable'
  352.     },
  353.     UIAspectRationConstraint = {
  354.         --data
  355.         'Name',
  356.         'Parent',
  357.         --behavior
  358.         'Archivable',
  359.         'AspectRation',
  360.         'AspectType',
  361.         'DominantAxis'
  362.     },
  363.     UIGridLayout = {
  364.         --appearance
  365.         'CellPadding',
  366.         'CellSize',
  367.         --data
  368.         'Name',
  369.         'Parent',
  370.         --behavior
  371.         'Archivable',
  372.         'FillDirection',
  373.         'FillDirectionMaxCells',
  374.         'HorizontalAlignment',
  375.         'SortOrder',
  376.         'StartCorner',
  377.         'VerticalAlignment'
  378.     },
  379.     UIListLayout = {
  380.         --appearance
  381.         'Padding',
  382.         --data
  383.         'Name',
  384.         'Parent',
  385.         --behavior
  386.         'Archivable',
  387.         'FillDirection',
  388.         'HorizontalAlignment',
  389.         'SortOrder',
  390.         'VerticalAlignment'
  391.     },
  392.     UIPadding = {
  393.         --data
  394.         'Name',
  395.         'Parent',
  396.         --behavior
  397.         'Archivable',
  398.         'PaddingBottom',
  399.         'PaddingLeft',
  400.         'PaddingRight',
  401.         'PaddingTop'
  402.     },
  403.     UIPageLayout = {
  404.         --appearance
  405.         'Animated',
  406.         'Circular',
  407.         'EasingDirection',
  408.         'EasingStyle',
  409.         'Padding',
  410.         'TweenTime',
  411.         --data
  412.         'Name',
  413.         'Parent',
  414.         --behavior
  415.         'Archivable',
  416.         'FillDirection',
  417.         'HorizontalAlignment',
  418.         'SortOrder',
  419.         'VerticalAlignment',
  420.         --input
  421.         'GamepadInputEnabled',
  422.         'ScrollWheelInputEnabled',
  423.         'TouchInputEnabled'
  424.     },
  425.     UIScale = {
  426.         --data
  427.         'Name',
  428.         'Parent',
  429.         --behavior
  430.         'Archivable',
  431.         'Scale'
  432.     },
  433.     UISizeConstraint = {
  434.         --data
  435.         'Name',
  436.         'Parent',
  437.         --behavior
  438.         'Archivable',
  439.         'MaxSize',
  440.         'MinSize'
  441.     },
  442.     UITableLayout = {
  443.         --appearance
  444.         'FillEmptySpaceColumns',
  445.         'FillEmptySpaceRows',
  446.         'Padding',
  447.         --data
  448.         'Name',
  449.         'Parent',
  450.         --behavior
  451.         'Archivable',
  452.         'FillDirection',
  453.         'HorizontalAlignment',
  454.         'MajorAxis',
  455.         'SortOrder',
  456.         'VerticalAlignment'
  457.     },
  458.     UITextSizeConstraint = {
  459.         --data
  460.         'Name',
  461.         'Parent',
  462.         --behavior
  463.         'Archivable',
  464.         'MaxTextSize',
  465.         'MinTextSize'
  466.     },
  467.     VideoFrame = {
  468.         --appearance
  469.         'SelectionImageObject',
  470.         --data
  471.         'Active',
  472.         'AnchorPoint',
  473.         'AutomaticSize',
  474.         'BackgroundColor3',
  475.         'BackgroundTransparency',
  476.         'BorderColor3',
  477.         'BorderMode',
  478.         'BorderSizePixel',
  479.         'LayoutOrder',
  480.         'Name',
  481.         'Parent',
  482.         'Position',
  483.         'Rotation',
  484.         'Selectable',
  485.         'Size',
  486.         'SizeConstraint',
  487.         'Visible',
  488.         'ZIndex',
  489.         --behavior
  490.         'Archivable',
  491.         'ClipsDescendants',
  492.         'NextSelectionDown',
  493.         'NextSelectionLeft',
  494.         'NextSelectionRight',
  495.         'NextSelectionUp',
  496.         --video
  497.         'Looped',
  498.         'Playing',
  499.         'Resolution',
  500.         'TimeLength',
  501.         'TimePosition',
  502.         'Video',
  503.         'Volume',
  504.         --localization
  505.         'AutoLocalize',
  506.         'RootLocalizationTable'
  507.     },
  508.     ViewportFrame = {
  509.         --appearance
  510.         'Ambient',
  511.         'LightColor',
  512.         'LightDirection',
  513.         'SelectionImageObject',
  514.         --data
  515.         'Active',
  516.         'AnchorPoint',
  517.         'AutomaticSize',
  518.         'BackgroundColor3',
  519.         'BackgroundTransparency',
  520.         'BorderColor3',
  521.         'BorderMode',
  522.         'BorderSizePixel',
  523.         'CurrentCamera',
  524.         'LayoutOrder',
  525.         'Name',
  526.         'Parent',
  527.         'Position',
  528.         'Rotation',
  529.         'Selectable',
  530.         'Size',
  531.         'SizeConstraint',
  532.         'Visible',
  533.         'ZIndex',
  534.         --behavior
  535.         'Archivable',
  536.         'ClipsDescendants',
  537.         'NextSelectionDown',
  538.         'NextSelectionLeft',
  539.         'NextSelectionRight',
  540.         'NextSelectionUp',
  541.         --image
  542.         'ImageColor3',
  543.         'ImageTransparency',
  544.         --localization
  545.         'AutoLocalize',
  546.         'RootLocalizationTable'
  547.     },
  548.     BillboardGui = {
  549.         --data
  550.         'Active',
  551.         'Adornee',
  552.         'AlwaysOnTop',
  553.         'Enabled',
  554.         'ExtentsOffset',
  555.         'ExtentsOffsetWorldSpace',
  556.         'LightInfluence',
  557.         'MaxDistance',
  558.         'Name',
  559.         'Parent',
  560.         'PlayerToHideFrom',
  561.         'ResetOnSpawn',
  562.         'Size',
  563.         'SizeOffset',
  564.         'StudsOffset',
  565.         'StudsOffsetWorldSpace',
  566.         'ZIndexBehavior',
  567.         --behavior
  568.         'Archivable',
  569.         'ClipsDescendants',
  570.         --localization
  571.         'AutoLocalize',
  572.         'RootLocalizationTable'
  573.     },
  574.     Hint = {
  575.         --appearance
  576.         'Text',
  577.         --data
  578.         'Name',
  579.         'Parent',
  580.         --behavior
  581.         'Archivable'
  582.     },
  583.     Message = {
  584.         --appearance
  585.         'Text',
  586.         --data
  587.         'Name',
  588.         'Parent',
  589.         --behavior
  590.         'Archivable'
  591.     },
  592.     BoolValue = {
  593.         --data
  594.         'Name',
  595.         'Parent',
  596.         'Value',
  597.         --behavior
  598.         'Archivable'
  599.     },
  600.     BrickColorValue = {
  601.         --data
  602.         'Name',
  603.         'Parent',
  604.         'Value',
  605.         --behavior
  606.         'Archivable'
  607.     },
  608.     CFrameValue = {
  609.         --data
  610.         'Name',
  611.         'Parent',
  612.         --behavior
  613.         'Archivable'
  614.     },
  615.     Color3Value = {
  616.         --data
  617.         'Name',
  618.         'Parent',
  619.         'Value',
  620.         --behavior
  621.         'Archivable'
  622.     },
  623.     IntValue = {
  624.         --data
  625.         'Name',
  626.         'Parent',
  627.         'Value',
  628.         --behavior
  629.         'Archivable'
  630.     },
  631.     NumberValue = {
  632.         --data
  633.         'Name',
  634.         'Parent',
  635.         'Value',
  636.         --behavior
  637.         'Archivable'
  638.     },
  639.     ObjectValue = {
  640.         --data
  641.         'Name',
  642.         'Parent',
  643.         'Value',
  644.         --behavior
  645.         'Archivable'
  646.     },
  647.     RayValue = {
  648.         --data
  649.         'Name',
  650.         'Parent',
  651.         --behavior
  652.         'Archivable'
  653.     },
  654.     StringValue = {
  655.         --data
  656.         'Name',
  657.         'Parent',
  658.         'Value',
  659.         --behavior
  660.         'Archivable'
  661.     },
  662.     Vector3Value = {
  663.         --data
  664.         'Name',
  665.         'Parent',
  666.         'Value',
  667.         --behavior
  668.         'Archivable'
  669.     },
  670.     Part = {
  671.         --appearance
  672.         'BrickColor',
  673.         'CastShadow',
  674.         'Color',
  675.         'Material',
  676.         'Reflectance',
  677.         'Transparency',
  678.         --data
  679.         'Name',
  680.         'Orientation',
  681.         'Parent',
  682.         'Position',
  683.         --[[--transform
  684.         'Origin Position',
  685.         'Origin Orientation',
  686.         --pivot
  687.         'Pivot Offset Position',
  688.         'Pivot Offset Orientation',]]
  689.         --behavior
  690.         'Anchored',
  691.         'Archivable',
  692.         'CanCollide',
  693.         'CanTouch',
  694.         'CollisionGroupId',
  695.         'Locked',
  696.         'Massless',
  697.         --part
  698.         'CustomPhysicalProperties',
  699.         'RootPriority',
  700.         'Shape',
  701.         'Size',
  702.         --assembly
  703.         'AssemblyLinearVelocity',
  704.         'AssemblyAngularVelocity'
  705.     },
  706.     MeshPart = {
  707.         --appearance
  708.         'BrickColor',
  709.         'CastShadow',
  710.         'Color',
  711.         'DoubleSided',
  712.         'Material',
  713.         'MeshId',
  714.         'Reflectance',
  715.         'RenderFidelity',
  716.         'TextureID',
  717.         'Transparency',
  718.         --data
  719.         'Name',
  720.         'Orientation',
  721.         'Parent',
  722.         'Position',
  723.         --[[--transform
  724.         'Origin Position',
  725.         'Origin Orientation',
  726.         --pivot
  727.         'Pivot Offset Position',
  728.         'Pivot Offset Orientation',]]
  729.         --behavior
  730.         'Anchored',
  731.         'Archivable',
  732.         'CanCollide',
  733.         'CanTouch',
  734.         'CollisionFidelity',
  735.         'CollisionGroupId',
  736.         'Locked',
  737.         'Massless',
  738.         --part
  739.         'CustomPhysicalProperties',
  740.         'RootPriority',
  741.         'Size',
  742.         --assembly
  743.         'AssemblyLinearVelocity',
  744.         'AssemblyAngularVelocity'
  745.     },
  746.     Humanoid = {
  747.         --data
  748.         'CameraOffset',
  749.         'DisplayDistanceType',
  750.         'DisplayName',
  751.         'HealthDisplayDistance',
  752.         'HealthDisplayType',
  753.         'Name',
  754.         'NameDisplayDistance',
  755.         'NameOcclusion',
  756.         'Parent',
  757.         'RigType',
  758.         --behavior
  759.         'Archivable',
  760.         'BreakJointsOnDeath',
  761.         'RequireNeck',
  762.         --jump settings
  763.         'AutoJumpEnabled',
  764.         'JumpPower',
  765.         'UseJumpPower',
  766.         --control
  767.         'AutoRotate',
  768.         'Jump',
  769.         'PlatformStand',
  770.         'Sit',
  771.         'TargetPoint',
  772.         'WalkToPart',
  773.         'WalkToPoint',
  774.         --game
  775.         'AutomaticScalingEnabled',
  776.         'Health',
  777.         'HipHeight',
  778.         'MaxHealth',
  779.         'MaxSlopeAngle',
  780.         'WalkSpeed'
  781.     },
  782.     BoxHandleAdornment = {
  783.         --appearance
  784.         'Color3',
  785.         'Transparency',
  786.         --data
  787.         'AdornCullingMode',
  788.         'Adornee',
  789.         'AlwaysOnTop',
  790.         'Name',
  791.         'Parent',
  792.         'Size',
  793.         'SizeRelativeOffset',
  794.         'Visible',
  795.         'ZIndex',
  796.         --behavior
  797.         'Archivable'
  798.     }
  799. }
  800.  
  801. _tolua.supported_datatypes = {'string','number','boolean','EnumItem','table','UDim2','UDim','Color3','Vector3','Vector2','Rect','BrickColor','ColorSequenceKeypoint','ColorSequence','NumberSequenceKeypoint','NumberSequence','NumberRange', 'Faces', 'Instance'}
  802. _tolua.supported_objects = {'ScreenGui','TextButton','TextLabel','TextBox','ImageLabel','ImageButton','Frame','ScrollingFrame','LocalScript','UIGradient','UIAspectRationConstraint','UIGridLayout','UIListLayout','UIPadding','UIPageLayout','UIScale','UISizeConstraint','UITableLayout','UITextSizeConstraint','VideoFrame','ViewportFrame','BillbaordGui','Hint','Message','BoolValue','BrickColorValue','CFrameValue','IntValue','NumberValue','ObjectValue','RayValue','StringValue','Vector3Value','Part','MeshPart', 'Humanoid', 'BoxHandleAdornment'}
  803.  
  804. function _tolua:fullname(object)
  805.     if object then
  806.         if object.Parent == game then
  807.             return 'game:GetService"'..object.ClassName..'"'
  808.         end
  809.         local result = object.Name
  810.         object = object.Parent
  811.         repeat wait()
  812.             if object then
  813.                 if object.Parent == game then
  814.                     result = "game:GetService'"..object.Name.."'." .. result
  815.                 else
  816.                     result = object.Name .. '.' .. result
  817.                 end
  818.                 object = object.Parent
  819.             end
  820.         until object == game
  821.         return result
  822.     end
  823. end
  824. function _tolua:tableToString(t, bool)
  825.     local result = ''
  826.     if bool then result = '\n' end
  827.     for a,b in pairs(t) do
  828.         if b then
  829.             if bool then
  830.                 result = result .. "'"..tostring(b).."'"
  831.             else
  832.                 result = result .. tostring(b)
  833.             end
  834.             if #t > 1 and a < #t then
  835.                 if bool then
  836.                     result = result .. ',\n'
  837.                 else
  838.                     result = result .. ', '
  839.                 end
  840.             end
  841.         end
  842.     end
  843.     return result
  844. end
  845.  
  846. function _string(input)
  847.     return "'"..tostring(input).."'"
  848. end
  849. function _number(input)
  850.     return tostring(input)
  851. end
  852. function color3(input)
  853.     return 'Color3.fromRGB('..tostring(input.R*255)..', '..tostring(input.G*255)..', '..tostring(input.B*255)..')'
  854. end
  855. function color_sequence_keypoint(input)
  856.     return 'ColorSequenceKeypoint.new('..input.Time..', '..color3(input.Value)..')'
  857. end
  858. function number_sequence_keypoint(input)
  859.     return 'NumberSequenceKeypoint.new('..input.Time..', '..input.Value..')'
  860. end
  861. function udim2(input)
  862.     return 'UDim2.new('..tostring(input.X)..', '..tostring(input.Y)..')'
  863. end
  864. function udim(input)
  865.     return 'UDim.new('..tostring(input.Scale)..', '..tostring(input.Offset)..')'
  866. end
  867. function vector3(input, _type)
  868.     return _type..'.new('..tostring(input)..')'
  869. end
  870. function brick_color(input)
  871.     return 'BrickColor.new("'..tostring(input)..'")'
  872. end
  873. function colorsequence(input)
  874.     local result = ''
  875.     for a,keypoint in pairs(input.Keypoints) do
  876.         if keypoint then
  877.             result = result .. color_sequence_keypoint(keypoint)
  878.             if #input.Keypoints > 1 and a < #input.Keypoints then
  879.                 result = result..', '
  880.             end
  881.         end
  882.     end
  883.     return 'ColorSequence.new({'..result..'})'
  884. end
  885. function numbersequence(input)
  886.     local result = ''
  887.     for a,keypoint in pairs(input.Keypoints) do
  888.         if keypoint then
  889.             result = result .. number_sequence_keypoint(keypoint)
  890.             if #input.Keypoints > 1 and a < #input.Keypoints then
  891.                 result = result..', '
  892.             end
  893.         end
  894.     end
  895.     return 'NumberSequence.new({'..result..'})'
  896. end
  897. function number_range(input)
  898.     return 'NumberRange.new('..input.Min..', '..input.Max..')'
  899. end
  900. function faces(input)
  901.     local result = ''
  902.     local t = string.split(tostring(input), ',')
  903.     for a,b in pairs(t) do
  904.         result = result .. 'Enum.NormalId.'..nospaces(tostring(b))
  905.         if #t > 1 and a < #t then
  906.             result = result .. ', '
  907.         end
  908.     end
  909.     return 'Faces.new('..result..')'
  910. end
  911. function instance(value, object)
  912.     if objects[value] then
  913.         return objects[value]
  914.     else
  915.         return fullname(value)
  916.     end
  917. end
  918.  
  919. function _tolua:ToString(value, object)
  920.     local t = typeof(value)
  921.     if t == 'string' then
  922.         return _string(value)
  923.     elseif t == 'number' or t == 'boolean' or t == 'EnumItem' then
  924.         return _number(value)
  925.     elseif t == 'table' then
  926.         return _tolua:tableToString(value)
  927.     elseif t == 'UDim2' then
  928.         return udim2(value)
  929.     elseif t == 'UDim' then
  930.         return udim(value)
  931.     elseif t == 'Color3' then
  932.         return color3(value)
  933.     elseif t == 'Vector3' or t == 'Vector2' or t == 'Rect' or t == 'CFrame' then
  934.         return vector3(value, t)
  935.     elseif t == 'BrickColor' then
  936.         return brick_color(value)
  937.     elseif t == 'ColorSequenceKeypoint' then
  938.         return color_sequence_keypoint(value)
  939.     elseif t == 'ColorSequence' then
  940.         return colorsequence(value)
  941.     elseif t == 'NumberSequenceKeypoint' then
  942.         return number_sequence_keypoint(value)
  943.     elseif t == 'NumberSequence' then
  944.         return numbersequence(value)
  945.     elseif t == 'NumberRange' then
  946.         return number_range(value)
  947.     elseif t == 'Faces' then
  948.         return faces(value)
  949.     elseif t == 'Instance' then
  950.         return instance(value, object)
  951.     end
  952.     return nil
  953. end
  954.  
  955. function _tolua:propertyToString(value, object, name)
  956.     local t = typeof(value)
  957.     local clone = Instance.new(object.ClassName)
  958.     if value == clone[name] then
  959.         return nil
  960.     else
  961.         if ToString(value, object) then
  962.             return ToString(value, object)
  963.         else
  964.             if name ~= 'Parent' then
  965.                 return tostring(value).." --Failed while trying to get "..object.Name.."s "..name..' so just used tostring.'
  966.             end
  967.         end
  968.     end
  969.     return tostring(value)
  970. end
  971. function _tolua:attributeToString(value, object, name)
  972.     local t = typeof(value)
  973.     if ToString(value, object) then
  974.         return ToString(value, object)
  975.     else
  976.         return "'Failed while trying to get "..object.Name.."s "..name.."'"
  977.     end
  978. end
  979.  
  980. function _tolua:getName()
  981.     local result = ''
  982.     for i = 1,5 do
  983.         result = result .. string.char(math.random(97,122))
  984.     end
  985.     return result
  986. end
  987. function _tolua:variablename(input)
  988.     local name = input.Name
  989.     local withoutIllegalCharacters = ''
  990.     for a in string.gmatch(name, '[%w_]') do
  991.         withoutIllegalCharacters = withoutIllegalCharacters .. a
  992.     end
  993.     local bname = ''
  994.     if #withoutIllegalCharacters == 0 then
  995.         bname = name
  996.     elseif string.find(string.sub(withoutIllegalCharacters, 1, 1), '%d') then
  997.         bname = '_' .. withoutIllegalCharacters
  998.     else
  999.         bname = withoutIllegalCharacters
  1000.     end
  1001.  
  1002.     local isduplicate = false
  1003.     if table.find(variableNames, bname) then
  1004.         isduplicate = true
  1005.     end
  1006.     if isduplicate then
  1007.         local count = 2
  1008.         while true do
  1009.             local dupe = false
  1010.             for a,b in pairs(variableNames) do
  1011.                 if b == bname..'_'..tostring(count) then
  1012.                     dupe = true
  1013.                     break
  1014.                 end
  1015.             end
  1016.             if not dupe then
  1017.                 table.insert(variableNames, bname..'_'..tostring(count))
  1018.                 objects[input] = bname..'_'..tostring(count)
  1019.                 return bname..'_'..tostring(count)
  1020.             end
  1021.             count = count + 1
  1022.         end
  1023.     else
  1024.         table.insert(variableNames, bname)
  1025.         objects[input] = bname
  1026.         return bname
  1027.     end
  1028.     table.insert(objects, input)
  1029.     objects[input] = bname
  1030.     return name
  1031. end
  1032.  
  1033. return _tolua
Add Comment
Please, Sign In to add comment