Motor Sınıfı
ScriptDocument
*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.
Özet
Yöntemler
MultiEditTextAsync(edits: {any}):Tuple |
Olaylar
SelectionChanged(positionLine: number,positionCharacter: number,anchorLine: number,anchorCharacter: number):RBXScriptSignal |
ViewportChanged(startLine: number,endLine: number):RBXScriptSignal |
API Referansı
Yöntemler
CloseAsync
Dönüşler
Kod Örnekleri
ScriptDocument:CloseAsync
`--!nocheck`
`-- Aşağıdaki kodu Komut Çubuğunda çalıştırın`
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
local scriptDocument
`-- İlk açık script belgesini bul`
for _, document in documents do
`-- Komut Çubuğu kapatılamaz, bu yüzden onu seçmeyin`
if not document:IsCommandBar() then
scriptDocument = document
break
end
end
if scriptDocument then
local success, err = scriptDocument:CloseAsync()
if success then
print(`Kapandı {scriptDocument.Name}`)
else
warn(`Kapatılamadı {scriptDocument.Name} çünkü: {err}`)
end
else
print("Açık script yok")
endEditTextAsync
ForceSetSelectionAsync
Dönüşler
Kod Örnekleri
ScriptDocument:ForceSetSelectionAsync()
--!nocheck
-- Aşağıdaki kodu bir script açıkken Komut Çubuğu'nda çalıştırın
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
-- İmlecin mevcut satırındaki metni alın
local cursorLine = scriptDocument:GetSelection()
local lineText = scriptDocument:GetLine(cursorLine)
-- Tüm metin satırını zorla seçin
local success, err = scriptDocument:ForceSetSelectionAsync(cursorLine, 1, cursorLine, #lineText + 1)
if success then
print("Seçim ayarlandı!")
else
print(`Seçimi ayarlamakta başarısız oldu çünkü: {err}`)
end
else
print("Açık script yok")
endGetLine
Parametreler
| Varsayılan değer: "nil" |
Dönüşler
Kod Örnekleri
ScriptDocument.SeçimDeğişti ve ScriptDocument:GetLine()
--!nocheck
-- Açıkken Komut Çubuğunda aşağıdaki kodu çalıştırın
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(`Seçilen: Satır {positionLine}, Karakter {positionCharacter}`)
print(`Nokta: Satır {anchorLine}, Karakter {anchorCharacter}`)
local lineText = scriptDocument:GetLine(positionLine)
print(`Seçilen satır metni: {lineText}`)
end)
else
print("Açık script yok")
endGetLineCount
Dönüşler
Kod Örnekleri
ScriptBelgesi:SatırSayısınıAl()
--!nocheck
-- Aşağıdaki kodu bir komut çubuğunda çalıştırın, bir script açıkken
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(`Scriptin {lineCount} satırı var!`)
else
print("Açık script yok")
endGetScript
Dönüşler
Kod Örnekleri
ScriptBelgesi:GetScript()
--!nocheck
-- Aşağıdaki kodu bir script açıkken Komut Çubuğu'nda çalıştırın
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(`Açık olan script: {openScript:GetFullName()}`)
else
print("Açık script yok")
endGetSelectedText
Dönüşler
Kod Örnekleri
ScriptDocument:SeçiliMetinVarMi() ve :GetSelectedText()
--!nocheck
-- Bir betik açıkken bu kodu Komut Çubuğunda çalıştırın
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(`Mevcut seçili metin: {selectedText}`)
else
print("Şu anda seçili metin yok")
end
end)
else
print("Açık betik yok")
endGetSelectionEnd
Dönüşler
Kod Örnekleri
ScriptDocument:GetSelectionStart() ve :GetSelectionEnd()
--!nocheck
-- Bir script açıkken aşağıdaki kodu Komut Çubuğunda çalıştırın
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(`Seçim başlangıcı: Satır {startLine}, Karakter {startCharacter}`)
print(`Seçim sonu: Satır {endLine}, Karakter {endCharacter}`)
else
print("Açık script yok")
endGetSelectionStart
Dönüşler
Kod Örnekleri
ScriptDocument:GetSelectionStart() ve :GetSelectionEnd()
--!nocheck
-- Bir script açıkken aşağıdaki kodu Komut Çubuğunda çalıştırın
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(`Seçim başlangıcı: Satır {startLine}, Karakter {startCharacter}`)
print(`Seçim sonu: Satır {endLine}, Karakter {endCharacter}`)
else
print("Açık script yok")
endGetText
Dönüşler
Kod Örnekleri
ScriptBelgesi:GetText()
--!nocheck
-- Aşağıdaki kodu bir script açıkken Komut Çubuğunda çalıştırın
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 içeriği: {text}`)
else
print("Açık hiçbir script yok")
endGetViewport
Dönüşler
Kod Örnekleri
ScriptBelgesi: Görünüm
--!nocheck
-- Aşağıdaki kodu bir script açıkken Komut Çubuğunda çalıştırın
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(`Şu anda {firstLine} ile {lastLine} arası satırlar görüntüleniyor`)
else
print("Açık script yok")
endHasSelectedText
Dönüşler
Kod Örnekleri
ScriptDocument:SeçiliMetinVarMi() ve :GetSelectedText()
--!nocheck
-- Bir betik açıkken bu kodu Komut Çubuğunda çalıştırın
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(`Mevcut seçili metin: {selectedText}`)
else
print("Şu anda seçili metin yok")
end
end)
else
print("Açık betik yok")
endIsCommandBar
Dönüşler
Kod Örnekleri
ScriptDocument:Komut Çubuğu mu?
--!nocheck
-- Aşağıdaki kodu Komut Çubuğunda çalıştırın
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if document:IsCommandBar() then
print("Komut çubuğu belgesi:", document)
end
endMultiEditTextAsync
RequestSetSelectionAsync
Dönüşler
Kod Örnekleri
ScriptDocument:RequestSetSelectionAsync()
--!nocheck
-- Aşağıdaki kodu bir script açıkken Komut Çubuğunda çalıştırın
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
-- İmlecin mevcut satırındaki metni alın
local cursorLine = scriptDocument:GetSelection()
local lineText = scriptDocument:GetLine(cursorLine)
-- Tüm metin satırını seçmek için zorlayın
local success, err = scriptDocument:RequestSetSelectionAsync(cursorLine, 1, cursorLine, #lineText + 1)
if success then
print("Seçim ayarlandı!")
else
print(`Seçim ayarlanamadı çünkü: {err}`)
end
else
print("Açık script yok")
endOlaylar
SelectionChanged
ScriptDocument.SelectionChanged(
Kod Örnekleri
ScriptDocument.SeçimDeğişti ve ScriptDocument:GetLine()
--!nocheck
-- Açıkken Komut Çubuğunda aşağıdaki kodu çalıştırın
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(`Seçilen: Satır {positionLine}, Karakter {positionCharacter}`)
print(`Nokta: Satır {anchorLine}, Karakter {anchorCharacter}`)
local lineText = scriptDocument:GetLine(positionLine)
print(`Seçilen satır metni: {lineText}`)
end)
else
print("Açık script yok")
endViewportChanged
Kod Örnekleri
ScriptDocument.ViewportChanged'e Bağlanıyor
--!nocheck
--[[
Çalıştırmak için:
1. Çıkış görünümünün açık olduğundan emin olun
2. Aşağıdaki kodu Komut Çubuğu'nda çalıştırın
3. Açılan Script penceresinde yukarı ve aşağı kaydırın
ViewportChanged olayından yazdırma ifadeleri Çıkış'ta görünecektir
]]
local Workspace = game:GetService("Workspace")
local ScriptEditorService = game:GetService("ScriptEditorService")
-- Birçok satırı kapsayan metin oluşturun
local dummyText = string.rep("-- Dummy Text\n", 60)
-- Dummy metni içeren bir script oluşturun ve açın
local otherScript = Instance.new("Script")
otherScript.Source = dummyText
otherScript.Parent = Workspace
local success, err = ScriptEditorService:OpenScriptDocumentAsync(otherScript)
if not success then
warn(`Script açılmadı çünkü: {err}`)
return
end
-- Açılan script'e referans alın
local scriptDocument = ScriptEditorService:FindScriptDocument(otherScript)
local function onViewportChanged(startLine: number, endLine: number)
print(`Script Görüntü Alanı Değişti - başlangıç Satırı: {startLine}, bitiş Satırı: {endLine}`)
end
-- Yukarıdaki fonksiyonu görüntü alanının güncellenmiş başlangıç ve bitiş satırını yazdıracak şekilde ViewportChanged olayına bağlayın
scriptDocument.ViewportChanged:Connect(onViewportChanged)