From a469089a6e41cd4dde2d6a42d7d80def54f7530b Mon Sep 17 00:00:00 2001 From: Lewin Kelly Date: Sun, 12 Mar 2023 11:05:08 +0000 Subject: [PATCH] Add basic instance system, similar to RbxUtility.Create --- melt.yml | 269 ++++++++++++++++++++++++++++++++++ selene.toml | 5 +- src/client/Client.client.lua | 1 - src/client/Client.client.luau | 19 +++ src/shared/melt/init.lua | 3 - src/shared/melt/init.luau | 163 ++++++++++++++++++++ 6 files changed, 455 insertions(+), 5 deletions(-) create mode 100644 melt.yml delete mode 100644 src/client/Client.client.lua create mode 100644 src/client/Client.client.luau delete mode 100644 src/shared/melt/init.lua create mode 100644 src/shared/melt/init.luau diff --git a/melt.yml b/melt.yml new file mode 100644 index 0000000..9011754 --- /dev/null +++ b/melt.yml @@ -0,0 +1,269 @@ +globals: + Accoutrement: + any: true + Animation: + any: true + AnimationController: + any: true + AnimationTrack: + any: true + ArcHandles: + any: true + Backpack: + any: true + BackpackItem: + any: true + BillboardGui: + any: true + BindableEvent: + any: true + BindableFunction: + any: true + BlockMesh: + any: true + BodyAngularVelocityBodyColors: + any: true + BodyForce: + any: true + BodyGyro: + any: true + BodyPosition: + any: true + BodyThrust: + any: true + BodyVelocity: + any: true + BoolValue: + any: true + BrickColorValue: + any: true + CFrameValue: + any: true + Camera: + any: true + CharacterMesh: + any: true + ClickDetector: + any: true + Clothing: + any: true + Color3Value: + any: true + Configuration: + any: true + CornerWedgePart: + any: true + CustomEvent: + any: true + CustomEventReceiver: + any: true + CylinderMesh: + any: true + DataModel: + any: true + Debris: + any: true + Decal: + any: true + Dialog: + any: true + DialogChoice: + any: true + DoubleConstrainedValue: + any: true + Explosion: + any: true + Feature: + any: true + FileMesh: + any: true + Fire: + any: true + Flag: + any: true + FlagStand: + any: true + FloorWire: + any: true + ForceField: + any: true + Frame: + any: true + Glue: + any: true + Handles: + any: true + Hat: + any: true + Hole: + any: true + HopperBin: + any: true + Humanoid: + any: true + ImageButton: + any: true + ImageLabel: + any: true + IntConstrainedValue: + any: true + IntValue: + any: true + JointInstance: + any: true + Keyframe: + any: true + Lighting: + any: true + LocalBackpack: + any: true + LocalScript: + any: true + Message: + any: true + Model: + any: true + ModuleScript: + any: true + Motor: + any: true + MotorFeature: + any: true + Mouse: + any: true + NetworkClient: + any: true + NetworkReplicator: + any: true + NetworkServer: + any: true + NumberValue: + any: true + ObjectValue: + any: true + Pants: + any: true + Part: + any: true + Platform: + any: true + Player: + any: true + PlayerGui: + any: true + Players: + any: true + Plugin: + any: true + PluginManager: + any: true + PluginMouse: + any: true + PointLight: + any: true + Pose: + any: true + ProfilingItem: + any: true + RayValue: + any: true + RemoteEvent: + any: true + RemoteFunction: + any: true + ReplicatedStorage: + any: true + RocketPropulsion: + any: true + RotateP: + any: true + RotateV: + any: true + ScreenGui: + any: true + Script: + any: true + ScriptContext: + any: true + Seat: + any: true + Selection: + any: true + SelectionBox: + any: true + SelectionPartLasso: + any: true + SelectionPointLasso: + any: true + Shirt: + any: true + ShirtGraphic: + any: true + SkateboardPlatform: + any: true + Skin: + any: true + Sky: + any: true + Smoke: + any: true + Snap: + any: true + Sound: + any: true + Sparkles: + any: true + SpawnLocation: + any: true + SpecialMesh: + any: true + SpotLight: + any: true + StarterGear: + any: true + StatsItem: + any: true + Status: + any: true + StringValue: + any: true + StudioTool: + any: true + SurfaceGui: + any: true + SurfaceSelection: + any: true + TaskScheduler: + any: true + Team: + any: true + Terrain: + any: true + TerrainRegion: + any: true + TextBox: + any: true + TextButton: + any: true + TextLabel: + any: true + Texture: + any: true + TextureTrail: + any: true + Tool: + any: true + TrussPart: + any: true + Vector3Value: + any: true + VehicleSeat: + any: true + VelocityMotor: + any: true + WedgePart: + any: true + Weld: + any: true + + \ No newline at end of file diff --git a/selene.toml b/selene.toml index c4ddb46..0bb0a20 100644 --- a/selene.toml +++ b/selene.toml @@ -1 +1,4 @@ -std = "roblox" +std = "roblox+melt" + +[lints] +global_usage = "allow" diff --git a/src/client/Client.client.lua b/src/client/Client.client.lua deleted file mode 100644 index c92eb29..0000000 --- a/src/client/Client.client.lua +++ /dev/null @@ -1 +0,0 @@ -print "Hello world, from client!" diff --git a/src/client/Client.client.luau b/src/client/Client.client.luau new file mode 100644 index 0000000..7761402 --- /dev/null +++ b/src/client/Client.client.luau @@ -0,0 +1,19 @@ +local ReplicatedStorage = game:GetService "ReplicatedStorage" +require(ReplicatedStorage.melt)() + +local localPlayer = game:GetService("Players").LocalPlayer + +ScreenGui { + Parent = localPlayer:WaitForChild "PlayerGui", + + Frame { + Size = UDim2.fromScale(0.5, 0.5), + + TextLabel { + Position = UDim2.fromScale(0.5, 0.5), + Text = "Hello world!", + TextSize = 24, + BackgroundTransparency = 1, + }, + }, +} diff --git a/src/shared/melt/init.lua b/src/shared/melt/init.lua deleted file mode 100644 index c819e8b..0000000 --- a/src/shared/melt/init.lua +++ /dev/null @@ -1,3 +0,0 @@ -return function() - print "Hello, world!" -end diff --git a/src/shared/melt/init.luau b/src/shared/melt/init.luau new file mode 100644 index 0000000..be37ad6 --- /dev/null +++ b/src/shared/melt/init.luau @@ -0,0 +1,163 @@ +local instances = { + "Accoutrement", + "Animation", + "AnimationController", + "AnimationTrack", + "ArcHandles", + "Backpack", + "BackpackItem", + "BillboardGui", + "BindableEvent", + "BindableFunction", + "BlockMesh", + "BodyAngularVelocityBodyColors", + "BodyForce", + "BodyGyro", + "BodyPosition", + "BodyThrust", + "BodyVelocity", + "BoolValue", + "BrickColorValue", + "CFrameValue", + "Camera", + "CharacterMesh", + "ClickDetector", + "Clothing", + "Color3Value", + "Configuration", + "CornerWedgePart", + "CustomEvent", + "CustomEventReceiver", + "CylinderMesh", + "Decal", + "Dialog", + "DialogChoice", + "DoubleConstrainedValue", + "Explosion", + "Feature", + "FileMesh", + "Fire", + "Flag", + "FlagStand", + "FloorWire", + "ForceField", + "Frame", + "Glue", + "Handles", + "Hat", + "Hole", + "HopperBin", + "Humanoid", + "ImageButton", + "ImageLabel", + "IntConstrainedValue", + "IntValue", + "JointInstance", + "Keyframe", + "LocalBackpack", + "LocalScript", + "Message", + "Model", + "ModuleScript", + "Motor", + "MotorFeature", + "Mouse", + "NetworkClient", + "NetworkReplicator", + "NetworkServer", + "NumberValue", + "ObjectValue", + "Pants", + "Part", + "Platform", + "Plugin", + "PluginManager", + "PluginMouse", + "PointLight", + "Pose", + "ProfilingItem", + "RayValue", + "RemoteEvent", + "RemoteFunction", + "ReplicatedStorage", + "RocketPropulsion", + "RotateP", + "RotateV", + "ScreenGui", + "Script", + "ScriptContext", + "Seat", + "Selection", + "SelectionBox", + "SelectionPartLasso", + "SelectionPointLasso", + "Shirt", + "ShirtGraphic", + "SkateboardPlatform", + "Skin", + "Sky", + "Smoke", + "Snap", + "Sound", + "Sparkles", + "SpawnLocation", + "SpecialMesh", + "SpotLight", + "StarterGear", + "StatsItem", + "Status", + "StringValue", + "StudioTool", + "SurfaceGui", + "SurfaceSelection", + "TaskScheduler", + "Team", + "Terrain", + "TerrainRegion", + "TextBox", + "TextButton", + "TextLabel", + "Texture", + "TextureTrail", + "Tool", + "TrussPart", + "Vector3Value", + "VehicleSeat", + "VelocityMotor", + "WedgePart", + "Weld", +} + +local globals = {} + +for _, objectType in ipairs(instances) do + globals[objectType] = function(dat) + local obj = Instance.new(objectType) + local parent + + for k, v in pairs(dat) do + if type(k) == "string" then + if k == "Parent" then + parent = v + else + obj[k] = v + end + elseif type(k) == "number" and type(v) == "userdata" then + v.Parent = obj + end + end + + obj.Parent = parent + + return obj + end +end + +return function() + -- Vomit everything into the global scope + local env = getfenv(0) + for k, v in globals do + env[k] = v + end + setfenv(0, env) +end