Add basic instance system, similar to RbxUtility.Create

This commit is contained in:
Lewin Kelly 2023-03-12 11:05:08 +00:00
parent 6d9de086d0
commit a469089a6e
No known key found for this signature in database
GPG Key ID: C103AD9C84014FD7
6 changed files with 455 additions and 5 deletions

269
melt.yml Normal file
View File

@ -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

View File

@ -1 +1,4 @@
std = "roblox"
std = "roblox+melt"
[lints]
global_usage = "allow"

View File

@ -1 +0,0 @@
print "Hello world, from client!"

View File

@ -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,
},
},
}

View File

@ -1,3 +0,0 @@
return function()
print "Hello, world!"
end

163
src/shared/melt/init.luau Normal file
View File

@ -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