Skip to content

Commit

Permalink
Use ScriptEditorService for updating Source (#370)
Browse files Browse the repository at this point in the history
We need to start using `UpdateSourceAsync` and `GetEditorSource` for
setting and getting `Script.Source` and `ModuleScript.Source`. So, this
does that, using `task.spawn` to make sure it isn't blocking as we
discussed elsewhere.
  • Loading branch information
Dekkonot authored Oct 13, 2023
1 parent a45310c commit e7a5b91
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 53 deletions.
10 changes: 9 additions & 1 deletion patches/lua-source-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@ Change:
# and it makes no sense for us to write it ourselves at this moment.
ScriptGuid:
Serialization:
Type: DoesNotSerialize
Type: DoesNotSerialize

Script:
Source:
Scriptability: Custom

ModuleScript:
Source:
Scriptability: Custom
31 changes: 31 additions & 0 deletions rbx_dom_lua/src/customProperties.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local CollectionService = game:GetService("CollectionService")
local ScriptEditorService = game:GetService("ScriptEditorService")

--- A list of `Enum.Material` values that are used for Terrain.MaterialColors
local TERRAIN_MATERIAL_COLORS = {
Expand Down Expand Up @@ -116,4 +117,34 @@ return {
end,
},
},
Script = {
Source = {
read = function(instance: Script)
return true, ScriptEditorService:GetEditorSource(instance)
end,
write = function(instance: Script, _, value: string)
task.spawn(function()
ScriptEditorService:UpdateSourceAsync(instance, function()
return value
end)
end)
return true
end,
},
},
ModuleScript = {
Source = {
read = function(instance: ModuleScript)
return true, ScriptEditorService:GetEditorSource(instance)
end,
write = function(instance: ModuleScript, _, value: string)
task.spawn(function()
ScriptEditorService:UpdateSourceAsync(instance, function()
return value
end)
end)
return true
end,
},
},
}
105 changes: 55 additions & 50 deletions rbx_dom_lua/src/database.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Version": [
0,
596,
597,
1,
5960685
5970668
],
"Classes": {
"Accessory": {
Expand Down Expand Up @@ -4504,6 +4504,17 @@
},
"DefaultProperties": {}
},
"AvatarCreationService": {
"Name": "AvatarCreationService",
"Tags": [
"NotCreatable",
"NotReplicated",
"Service"
],
"Superclass": "Instance",
"Properties": {},
"DefaultProperties": {}
},
"AvatarEditorService": {
"Name": "AvatarEditorService",
"Tags": [
Expand Down Expand Up @@ -15560,9 +15571,7 @@
},
"DragDetector": {
"Name": "DragDetector",
"Tags": [
"NotBrowsable"
],
"Tags": [],
"Superclass": "ClickDetector",
"Properties": {
"ActivatedCursorIcon": {
Expand Down Expand Up @@ -28121,6 +28130,17 @@
}
}
},
"LogReporterService": {
"Name": "LogReporterService",
"Tags": [
"NotCreatable",
"NotReplicated",
"Service"
],
"Superclass": "Instance",
"Properties": {},
"DefaultProperties": {}
},
"LogService": {
"Name": "LogService",
"Tags": [
Expand Down Expand Up @@ -31192,7 +31212,7 @@
},
"Source": {
"Name": "Source",
"Scriptability": "ReadWrite",
"Scriptability": "Custom",
"DataType": {
"Value": "String"
},
Expand Down Expand Up @@ -41454,7 +41474,7 @@
"Properties": {
"Source": {
"Name": "Source",
"Scriptability": "ReadWrite",
"Scriptability": "Custom",
"DataType": {
"Value": "String"
},
Expand Down Expand Up @@ -47977,6 +47997,19 @@
}
}
},
"Camera Speed Adjust Binding": {
"Name": "Camera Speed Adjust Binding",
"Scriptability": "ReadWrite",
"DataType": {
"Enum": "CameraSpeedAdjustBinding"
},
"Tags": [],
"Kind": {
"Canonical": {
"Serialization": "Serializes"
}
}
},
"Camera Zoom to Mouse Position": {
"Name": "Camera Zoom to Mouse Position",
"Scriptability": "ReadWrite",
Expand Down Expand Up @@ -49545,7 +49578,9 @@
},
"StudioAttachment": {
"Name": "StudioAttachment",
"Tags": [],
"Tags": [
"NotReplicated"
],
"Superclass": "Instance",
"Properties": {
"AutoHideParent": {
Expand Down Expand Up @@ -49614,52 +49649,11 @@
}
}
},
"DefaultProperties": {
"Attributes": {
"Attributes": {}
},
"AutoHideParent": {
"Bool": false
},
"Capabilities": {
"SecurityCapabilities": 0
},
"DefinesCapabilities": {
"Bool": false
},
"IsArrowVisible": {
"Bool": false
},
"Offset": {
"Vector2": [
0.0,
0.0
]
},
"SourceAnchorPoint": {
"Vector2": [
0.0,
0.0
]
},
"SourceAssetId": {
"Int64": -1
},
"Tags": {
"Tags": []
},
"TargetAnchorPoint": {
"Vector2": [
0.0,
0.0
]
}
}
"DefaultProperties": {}
},
"StudioCallout": {
"Name": "StudioCallout",
"Tags": [
"NotCreatable",
"NotReplicated"
],
"Superclass": "Instance",
Expand Down Expand Up @@ -64701,6 +64695,14 @@
"EdgeBump": 1
}
},
"CameraSpeedAdjustBinding": {
"name": "CameraSpeedAdjustBinding",
"items": {
"AltScroll": 2,
"None": 0,
"RmbScroll": 1
}
},
"CameraType": {
"name": "CameraType",
"items": {
Expand Down Expand Up @@ -67514,6 +67516,9 @@
"Mid": 36,
"Midlight": 98,
"Notification": 4,
"OnboardingCover": 132,
"OnboardingHighlight": 133,
"OnboardingShadow": 134,
"RibbonButton": 19,
"RibbonTab": 15,
"RibbonTabTopBar": 16,
Expand Down
1 change: 1 addition & 0 deletions rbx_reflection_database/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# rbx\_reflection_database Changelog

## Unreleased Changes
* Updated to Roblox version 597

## 0.2.9+roblox-596 (2023-10-03)
## 0.2.8+roblox-296 (incorrect metadata)
Expand Down
Binary file modified rbx_reflection_database/database.msgpack
Binary file not shown.
3 changes: 1 addition & 2 deletions rbx_types/src/attributes/writer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{
borrow::Borrow,
collections::BTreeMap,
io::{self, Write},
};
Expand All @@ -24,7 +23,7 @@ pub(crate) fn write_attributes<W: Write>(
writer.write_all(&(map.len() as u32).to_le_bytes())?;

for (name, variant) in map {
let variant = variant.borrow();
let variant = variant;

write_string(&mut writer, name)?;

Expand Down

0 comments on commit e7a5b91

Please sign in to comment.