ScriptDocument

Artık kullanılmayanları göster

*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.

Oluşturulamaz
Çoğaltılmamış

Bir ScriptDocument örneği, bir Studio Kılavuzu Editörü belgesinin bir proxy'sidir.Editörde açılan LuaSourceContainer ile farklıdır, çünkü açık bir belgenin geçici durumunu temsil eder ve temsilinin okuma ve kod düzenleme için daha uygun bir formatta olması daha uygundur.Özellikle, ScriptDocument açık kaynağın özelliklerine sahip olmadığı Taslak Moduna yapılan herhangi bir değişikliği yansıtır, ki bunlar kaynağın özellikleri değildir.

Senaryo Editörü'nün kendisi mevcut ve herhangi bir DataModel 'dan farklı bir iş parçacığında değişiyor, bu yüzden ScriptDocument açık Senaryo Editörü'nü yeniden yazıyor, ancak açık editör değil.Replikasyon nedeniyle, bazen editördeki metni değiştirmek ve güncelleştirmek arasında hafif bir gecikme olur.Gecikme genellikle DataModel meşgul olduğundan kaynaklanır ve neredeyse daima son derece küçüktür, ancak hala var.

Bir ScriptDocument 'nin varlığı, bir belgenin Script Düzenleyicisi'nde açık olduğunu gösterir.Tüm ScriptDocument örneklerinin ebeveyni ScriptEditorService dir.Her bir örnek aşağıdaki kodlama konvansiyonlarına uyuyor:

  • ScriptDocument içindeki tüm metin UTF-8 kodlanmıştır.
  • Tüm satır indeksleri 1 indeksli.
  • Tüm karakter indeksleri 1 indeksli ve UTF-8 baytları sayar, grafemler değil, bu yüzden aynı uyarı TextBox.CursorPosition uygulanır: çok sayıda Unicode karakteri birden fazla bayt alır.
  • Tüm menziller başlangıç pozisyonlarını ve son pozisyonlarını içerir ve özel değildir, bu yüzden başlangıç == son boş bir menzil içerir.

ScriptDocument için tüm API'ler Plugin seviye güvenlikte.

Özet

Yöntemler

  • GetLine(lineIndex : number?):string
    Eklenti Güvenliği

    Belirtilen satırın metnini döndürür. Bir argüman verilmediğinde, mevcut işaretçi konumunun satırını döndürür.

  • Eklenti Güvenliği

    Belgedeki satır sayısını döndürür.

  • Eklenti Güvenliği

    Eğer bir tane varsa temel LuaSourceContainer durumdöndürür, aksi takdirde nil .

  • Eklenti Güvenliği

    Editörde seçilen metni veya seçim yoksa boş bir dizeyi alır.

  • Eklenti Güvenliği

    Script Düzenleyici'nin son bilinen seçimini format olarak döndürür: CursorLine, CursorChar, AnchorLine, AnchorChar . Eğer Script Düzenleyici'nin seçeneği yoksa, CursorLine == AnchorLine ve CursorChar == AnchorChar .

  • Eklenti Güvenliği

    Kurma konumunun ve sabitin en büyüğünü alır. Eğer editörde seçenek yoksa, aynı değerdir.

  • Eklenti Güvenliği

    İşaretçi konumunun ve bağlantının en küçüğünü alır. Eğer editörde seçenek yoksa, aynı değerdir.

  • GetText(startLine : number?,startCharacter : number?,endLine : number?,endCharacter : number?):string
    Eklenti Güvenliği

    Açık editörden metin döndürür.

  • Eklenti Güvenliği

    Düzenleyici değişiklikte şu anda gösterilen satır numaralarını geri döndürür.

  • Eklenti Güvenliği

    Editörün herhangi bir metin seçip seçmediğini döndürür.

  • Eklenti Güvenliği

    ScriptDocument Komut çubuğunu temsil ediyorsa gerçek döndürür.

  • Bekletir
    Eklenti Güvenliği

    Editörün bu belge ile ilişkili olduğu istekler kapatılır. Editör, talepyanıt verene kadar mevcut iş parçasını verir.

  • EditTextAsync(newText : string,startLine : number,startCharacter : number,endLine : number,endCharacter : number):Tuple
    Bekletir
    Eklenti Güvenliği

    Belirtilen aralıktaki metni ( startLine , startColumn ) yeni metin ile değiştirir ( endLine , endColumn ).

  • ForceSetSelectionAsync(cursorLine : number,cursorCharacter : number,anchorLine : number?,anchorCharacter : number?):Tuple
    Bekletir
    Eklenti Güvenliği

    Düzenleyiciye, kuruluş seçimini argüman değerlerine ayarlamasını ister.

  • Bekletir
    Eklenti Güvenliği
  • RequestSetSelectionAsync(cursorLine : number,cursorCharacter : number,anchorLine : number?,anchorCharacter : number?):Tuple
    Bekletir
    Eklenti Güvenliği

    Düzenleyiciye, kuruluş seçimini argüman değerlerine ayarlamasını ister.

Etkinlikler

Özellikler

Yöntemler

GetLine

Eklenti Güvenliği

Belirtilen satırın metnini döndürür. Bir argüman verilmediğinde, mevcut işaretçi konumunun satırını döndürür.

Parametreler

lineIndex: number
Varsayılan değer: "nil"

Dönüşler

Kod Örnekleri

ScriptDocument.SelectionChanged and ScriptDocument:GetLine()

ScriptDocument.SelectionChanged and ScriptDocument:GetLine()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function(positionLine, positionCharacter, anchorLine, anchorCharacter)
print(`Selected: Line {positionLine}, Char {positionCharacter}`)
print(`Anchor: Line {anchorLine}, Char {anchorCharacter}`)
local lineText = scriptDocument:GetLine(positionLine)
print(`Selected line text: {lineText}`)
end)
else
print("No scripts open")
end

GetLineCount

Eklenti Güvenliği

Aktif belgedeki satır sayısını döndürür.


Dönüşler

Kod Örnekleri

ScriptDocument:GetLineCount()

ScriptDocument:GetLineCount()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local lineCount = scriptDocument:GetLineCount()
print(`The script has {lineCount} lines!`)
else
print("No scripts open")
end
Eklenti Güvenliği

Eğer bir tane varsa temel LuaSourceContainer durumdöndürür, aksi takdirde nil .


Dönüşler

Kod Örnekleri

ScriptDocument:GetScript()

ScriptDocument:GetScript()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local openScript = scriptDocument:GetScript()
print(`Currently open script: {openScript:GetFullName()}`)
else
print("No scripts open")
end

GetSelectedText

Eklenti Güvenliği

Editörde seçilen metni veya seçim yoksa boş bir dizeyi alır.


Dönüşler

Kod Örnekleri

ScriptDocument:HasSelectedText() and :GetSelectedText()

ScriptDocument:HasSelectedText() and :GetSelectedText()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function()
if scriptDocument:HasSelectedText() then
local selectedText = scriptDocument:GetSelectedText()
print(`Currently selected text: {selectedText}`)
else
print("No text currently selected")
end
end)
else
print("No scripts open")
end

GetSelection

Eklenti Güvenliği

Script Düzenleyici'nin son bilinen seçimini format olarak döndürür: CursorLine, CursorChar, AnchorLine, AnchorChar . Eğer Script Düzenleyici'nin seçeneği yoksa, CursorLine == AnchorLine ve CursorChar == AnchorChar .


Dönüşler

Kuruluş Çizgisi, İşaretleme Çizgisi, Ankör Çizgisi, Ankör İşaretleme.

GetSelectionEnd

Eklenti Güvenliği

Kurma konumunun ve sabitin en büyüğünü alır. Eğer editörde seçenek yoksa, aynı değerdir.


Dönüşler

Kod Örnekleri

ScriptDocument:GetSelectionStart() and :GetSelectionEnd()

ScriptDocument:GetSelectionStart() and :GetSelectionEnd()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local startLine, startCharacter = scriptDocument:GetSelectionStart()
local endLine, endCharacter = scriptDocument:GetSelectionEnd()
print(`Selection start: Line {startLine}, Char {startCharacter}`)
print(`Selection end: Line {endLine}, Char {endCharacter}`)
else
print("No scripts open")
end

GetSelectionStart

Eklenti Güvenliği

İşaretçi konumunun ve bağlantının en küçüğünü alır. Eğer editörde seçenek yoksa, aynı değerdir.


Dönüşler

Kod Örnekleri

ScriptDocument:GetSelectionStart() and :GetSelectionEnd()

ScriptDocument:GetSelectionStart() and :GetSelectionEnd()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local startLine, startCharacter = scriptDocument:GetSelectionStart()
local endLine, endCharacter = scriptDocument:GetSelectionEnd()
print(`Selection start: Line {startLine}, Char {startCharacter}`)
print(`Selection end: Line {endLine}, Char {endCharacter}`)
else
print("No scripts open")
end

GetText

Eklenti Güvenliği

Açık editörden metin döndürür. 0, 2 veya 4 argümanla çağrılmalıdır:

  • 0 argüman ile çağrılırsa, açık editörün tüm içeriğini alır.
  • 2 argümanla çağrıldığında, belgenin başlangıcındaki metni alır ( startLine , startColumn ).
  • 4 argümanla çağrıldığında, belgenin başlangıcındaki metni alır ( startLine , startColumn ) ve bitişindeki metni alır ( endLine , endColumn ).

Parametreler

startLine: number
Varsayılan değer: "nil"
startCharacter: number
Varsayılan değer: "nil"
endLine: number
Varsayılan değer: "nil"
endCharacter: number
Varsayılan değer: "nil"

Dönüşler

Kod Örnekleri

ScriptDocument:GetText()

ScriptDocument:GetText()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local text = scriptDocument:GetText()
print(`Script contents: {text}`)
else
print("No scripts open")
end

GetViewport

Eklenti Güvenliği

Düzenleyici değişiklikte şu anda gösterilen satır numaralarını geri döndürür.Editör, başlangıç çizgisi ve bitiş çizgisi arasındaki satırları gösterir, dahil.İlk ve son satır yalnızca kısmen görünebilir.Örneğin, son satırın en üst pikeli sadece ekranda olabilir.Ayrıca, kod katlanması başlangıç çizgisi ile bitiş çizgisi arasındaki satırları gizleyebilir.


Dönüşler

Kod Örnekleri

ScriptDocument:GetViewport

ScriptDocument:GetViewport

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local firstLine, lastLine = scriptDocument:GetViewport()
print(`Currently viewing lines {firstLine} to {lastLine}`)
else
print("No scripts open")
end

HasSelectedText

Eklenti Güvenliği

Editörün herhangi bir metin seçip seçmediğini döndürür.


Dönüşler

Kod Örnekleri

ScriptDocument:HasSelectedText() and :GetSelectedText()

ScriptDocument:HasSelectedText() and :GetSelectedText()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function()
if scriptDocument:HasSelectedText() then
local selectedText = scriptDocument:GetSelectedText()
print(`Currently selected text: {selectedText}`)
else
print("No text currently selected")
end
end)
else
print("No scripts open")
end

IsCommandBar

Eklenti Güvenliği

Gerçek döndürürse ScriptDocument Komut çubuğunu temsil ediyorsa. Komut çubuğunun bu API'de özel kuralları ve sınırları vardır:

  • Stüdyo, eklentileri çalıştırmadan önce Komut çubuğunu oluşturur, bu yüzden açılan olayı her zaman ateş etmez, ancak DataModels arasında geçiş yaparken Studio'nun kapandığını ve yeniden açıldığını unutmaz.
  • Güvenlik nedenleriyle Komut çubuğunu EditTextAsync ile düzenleyemezsiniz.

Dönüşler

Kod Örnekleri

ScriptDocument:IsCommandBar()

ScriptDocument:IsCommandBar()

--!nocheck
-- Run the following code in the Command Bar
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if document:IsCommandBar() then
print("Command bar document:", document)
end
end

CloseAsync

Bekletir
Eklenti Güvenliği

Bu belge ile ilişkili olan editörün kapatması gereken istekler.Düzenleyici isteğe yanıt verene kadar mevcut iş parçasını verir.Eğer işlev başarılı olursa, geri döner (true, nil).Eğer işlev başarısız olursa, sorunun açıklaması olarak geri döner (false, dizi).

Bu işlev komut çubuğunu kapatamaz.


Dönüşler

Kod Örnekleri

ScriptDocument:CloseAsync

ScriptDocument:CloseAsync

--!nocheck
-- Run the following code in the Command Bar
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
local scriptDocument
-- Find the first open script document
for _, document in documents do
-- The Command Bar can't be closed, so don't select it
if not document:IsCommandBar() then
scriptDocument = document
break
end
end
if scriptDocument then
local success, err = scriptDocument:CloseAsync()
if success then
print(`Closed {scriptDocument.Name}`)
else
warn(`Failed to close {scriptDocument.Name} because: {err}`)
end
else
print("No open scripts")
end

EditTextAsync

Bekletir
Eklenti Güvenliği

Belirtilen aralıktaki metni ( startLine , startColumn ) ile değiştirir ( endLine , endColumn ) ile newText .Menzil boşsa, işlev metni ( startLine , startColumn ) girer.Metin imlecisi belirtilen aralığın içindeyse, imleç düzenlemenin son konumuna hareket eder.Aksi takdirde, metin imleci hareket etmez.Bu işlev, düzenleyici tarafından düzenlemeyle ilgili bir yanıt alana kadar mevcut iş parçacığını verir.

Eğer işlev başarılı olursa, geri döner ( true , nil ).

Fonksiyon bir hata atar if:

  • Menzil geçersizdir.
  • Menzil bir Unicode karakterini dilimleyecekti, örneğin Unicode karakterinin yalnızca bazı baytlerini değiştirecekti.
  • The newText kendisi geçersiz UTF-8 içerir.

Eğer işlev başarısız olursa, geri döner (false, dizi).Dize, sorunun açıklamasıdır.En yaygın başarısızlık türü bir sürüm uyuşmazlığıdır.Bu, EditTextAsync editörün içeriği ile uyumsuz olduğu sırada ScriptDocument çağırmaya çalıştığınızda meydana gelir.Eğer bu gerçekleşirse, düzenlemeyi yeniden deneyebilirsiniz.

Parametreler

newText: string
Varsayılan değer: ""
startLine: number
Varsayılan değer: ""
startCharacter: number
Varsayılan değer: ""
endLine: number
Varsayılan değer: ""
endCharacter: number
Varsayılan değer: ""

Dönüşler

ForceSetSelectionAsync

Bekletir
Eklenti Güvenliği

Düzenleyiciye, kuruluş seçimini argüman değerlerine ayarlamasını ister.Her iki anahtar argüman geçmeli veya her ikisi de olmalıdır.Her ikisi de geçmezse, her biri aynı kurallara sahip olmak üzere geçerli işaretçi argümanına eşit olur.Dokümanın metin içeriği değiştiğinde editör, okuyucusunu güncellemeyi reddedebilir.Farklı olarak ScriptDocument:RequestSetSelectionAsync() , düzenleyici, istek yapıldığından bu yana kursozu hareket ettirmeyi reddetmeyecektir, eğer kursoz hareket ettiyse.İşaretçi güncellendiyse (true, nil) ve güncellenmediyse (false, dizi) açıklama dizesi ile döndürür.Düzenleyici yanıt verene kadar mevcut iş parçasını verir.

Parametreler

cursorLine: number
Varsayılan değer: ""
cursorCharacter: number
Varsayılan değer: ""
anchorLine: number
Varsayılan değer: "nil"
anchorCharacter: number
Varsayılan değer: "nil"

Dönüşler

Kod Örnekleri

ScriptDocument:ForceSetSelectionAsync()

ScriptDocument:ForceSetSelectionAsync()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
-- Get the text on the cursor's current line
local cursorLine = scriptDocument:GetSelection()
local lineText = scriptDocument:GetLine(cursorLine)
-- Force select the entire line of text
local success, err = scriptDocument:ForceSetSelectionAsync(cursorLine, 1, cursorLine, #lineText + 1)
if success then
print("Set selection!")
else
print(`Failed to set selection because: {err}`)
end
else
print("No scripts open")
end

MultiEditTextAsync

Bekletir
Eklenti Güvenliği

Parametreler

edits: Array
Varsayılan değer: ""

Dönüşler

RequestSetSelectionAsync

Bekletir
Eklenti Güvenliği

Düzenleyiciye, kuruluş seçimini argüman değerlerine ayarlamasını ister.Her iki anahtar argüman geçmeli veya her ikisi de olmalıdır.Her ikisi de geçmezse, her biri aynı kurallara sahip olmak üzere geçerli işaretçi argümanına eşit olur.Düzenleyici, belgenin metin içeriği değiştiğinde veya istek yapıldığından bu yana kurpozör hareket ettiğinde kurpozörün güncellenmesini reddedebilir.İşaretçi güncellendiyse (true, nil) ve güncellenmediyse (false, dizi) açıklama dizesi ile döndürür.Düzenleyici yanıt verene kadar mevcut iş parçasını verir.

Parametreler

cursorLine: number
Varsayılan değer: ""
cursorCharacter: number
Varsayılan değer: ""
anchorLine: number
Varsayılan değer: "nil"
anchorCharacter: number
Varsayılan değer: "nil"

Dönüşler

Kod Örnekleri

ScriptDocument:RequestSetSelectionAsync()

ScriptDocument:RequestSetSelectionAsync()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
-- Get the text on the cursor's current line
local cursorLine = scriptDocument:GetSelection()
local lineText = scriptDocument:GetLine(cursorLine)
-- Force select the entire line of text
local success, err = scriptDocument:RequestSetSelectionAsync(cursorLine, 1, cursorLine, #lineText + 1)
if success then
print("Set selection!")
else
print(`Failed to set selection because: {err}`)
end
else
print("No scripts open")
end

Etkinlikler

SelectionChanged

Eklenti Güvenliği

Bir metin değişikliğinden hemen sonra dahil olmak üzere ScriptDocument değiştiğinde ateş eder.

Parametreler

positionLine: number
positionCharacter: number
anchorLine: number
anchorCharacter: number

Kod Örnekleri

ScriptDocument.SelectionChanged and ScriptDocument:GetLine()

ScriptDocument.SelectionChanged and ScriptDocument:GetLine()

--!nocheck
-- Run the following code in the Command Bar while a script is open
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function(positionLine, positionCharacter, anchorLine, anchorCharacter)
print(`Selected: Line {positionLine}, Char {positionCharacter}`)
print(`Anchor: Line {anchorLine}, Char {anchorCharacter}`)
local lineText = scriptDocument:GetLine(positionLine)
print(`Selected line text: {lineText}`)
end)
else
print("No scripts open")
end

ViewportChanged

Eklenti Güvenliği

Düzenleyicide gösterilen satır numaraları değiştiğinde ateş eder. Ayrıntılar için ScriptDocument.GetViewport bakın.

Parametreler

startLine: number
endLine: number

Kod Örnekleri

Demonstrates using ScriptDocument.ViewportChanged to print the start and end line of the script's viewport when it changes.

To run:

  1. Ensure Output view is open
  2. Run the below code in the Command Bar
  3. Scroll up and down in the opened Script window
Connecting to ScriptDocument.ViewportChanged

--!nocheck
--[[
To run:
1. Ensure Output view is open
2. Run the below code in the Command Bar
3. Scroll up and down in the opened Script window
Print statements from the ViewportChanged event will appear in the Output
]]
local Workspace = game:GetService("Workspace")
local ScriptEditorService = game:GetService("ScriptEditorService")
-- Create text that spans many lines
local dummyText = string.rep("-- Dummy Text\n", 60)
-- Create a script containing the dummy text and open it
local otherScript = Instance.new("Script")
otherScript.Source = dummyText
otherScript.Parent = Workspace
local success, err = ScriptEditorService:OpenScriptDocumentAsync(otherScript)
if not success then
warn(`Failed to open script because: {err}`)
return
end
-- Get a reference to the opened script
local scriptDocument = ScriptEditorService:FindScriptDocument(otherScript)
local function onViewportChanged(startLine: number, endLine: number)
print(`Script Viewport Changed - startLine: {startLine}, endLine: {endLine}`)
end
-- Connect the ViewportChanged event to the function above that prints the start and end line of the updated viewport
scriptDocument.ViewportChanged:Connect(onViewportChanged)