-
Notifications
You must be signed in to change notification settings - Fork 0
Editor Instance
This page will help you understand Editor instances.
-
Editor Instancecan be created thruGEditor:Get(CUSTOM_NAME). - If editor with that name already exists, it will return existing one.
To get Editor Instance, you should use GEditor:Get().
Frame: GuiObject
Script Editor frame.
local Childrens = #Editor.Frame:GetChildren() - 1
print(`Frame children count: {Childrens}`)Name: string
Important
This variable is read only, which means it won't change name of Editor itself.
Reference to the editor key in GEditor.__Editors.
print(Editor.Name)ConstLineCount: number
Important
This variable is read only, changing this variable will result in bugs.
Count of the lines that will only grow as new lines getting created.
print(`Total lines created thru session: {Editor.ConstLineCount}`)Captured: bool
Important
This variable is read only, changing this variable will result in bugs.
Identifies if player is captured into script editor or not.
Indentation: bool
If set to true, indentation will be automaticly added to every line.
Editor.Indentation = falseLines: table
Contains every existing line instance at the moment.
local Line = Editor.Lines[2]
if not Line then
return
end
Line.Frame.Box.Text = "-- Hello!"
print(Line.Text)Editor Instance can be customized:
Fonts: table
- LineBox: Font of the line textbox.
- LineNumber: Font of the line count visualisation.
Colors: table
- Line: Color of the line frame.
- LineNumber: Color of the line count visualisation.
- LineBox:
- Text: Color of the line textbox text.
- Placeholder: Color of the line textbox placeholder text.
Sizes: table
- Line UDim2: Size of each line.
- LineBox number: Size of line textbox textsize.
- CursorOffset Vector2: Scrolling offset of the script editor.
Padding: UDim
Distance between each line.
local Editor = GEditor:Get("Test")
Editor.Frame.Parent = script.Parent
Editor.Colors.Line = Color3.new(0.0196078, 0.647059, 0.25098)
Editor.Colors.LineNumber = Color3.new(0.913725, 1, 0.341176)
Editor.Sizes.Line = UDim2.new(1, 0, .3, 0)
You can set default text and lines by LineTexts variable.
Template:
local Editor = GEditor:Get("Test")
Editor.Frame.Parent = Gui
Editor.LineTexts = {
[1] = {
Text = `print("Hello world!")`,
Placeholder = ""
},
[2] = {
Text = `-- Foo bar`,
Placeholder = ""
},
[3] = {
Text = ``,
Placeholder = "..Script here.."
},
}
Editor:DefaultText()
Capture: (self: Editor Instance) -> ()
Captures player into script editor.
Editor:Capture()UnCapture: (self: Editor Instance) -> ()
Frees player into script editor.
Editor:UnCapture()GetText: (self: Editor Instance) -> string
Returns text from all of the lines.
print(Editor:GetText())Clear: (self: Editor Instance) -> string
Cleares all lines and returns text from all of the lines.
print(Editor:Clear())Remove: (self: Editor Instance) -> ()
Removes Editor Instance.
Editor:Remove()GetLineCount: (self: Editor Instance) -> number
Returns count of all existing lines at the moment.
print(Editor:GetLineCount())GetCursorPosition: (self: Editor Instance, Default: bool?) -> UDim2
Returns cursor position in UDim2 if player is focused on any line of script editor.
print(Editor:GetCursorPosition())ChangeLine: (self: Editor Instance) -> ()
Note
Use at your own risk.
If player is focused on any of the line's textboxes, player will be transfered to the CurrentLine + ToAdd line.
Editor:ChangeLine(1)
task.wait(.5)
Editor:ChangeLine(1)
task.wait(.5)
Editor:ChangeLine(-1)
task.wait(.5)
Editor:ChangeLine(-1)CreateLine: (self: Editor Instance, FromLine: number?, FromCursor: bool?) -> Line Instance
Creates new line instance.
If FromLine is specified, will create new line from that index.
If FromLine is NOT specified, will create new line as the last one.
If FromCursor is specified, text after CursorPosition of the previous line will be transfered to the created line.
local Line = Editor:CreateLine(3)
print(Line:GetIndex())Using FromCursor:
local Line = Editor:CreateLine(3, true)
print(Line.Text)RemoveLine: (self: [Editor Instance](https://github.com/gdr1461/GEditor/wiki/Editor-Instance, TransferText: bool?), Line: number?) -> ()
Removes existing line instance.
If Line is not specified, will remove last line.
If TransferText is specified, text from deleted line will be transfered to its neighbour.
Editor:RemoveLine(5)Using TransferText:
Editor:RemoveLine(5, true)
print(Editor.Lines[4].Text)DefaultText: (self: Editor Instance) -> ()
Updates all of the lines to the LineTexts.
Editor:DefaultText()Refresh: (self: Editor Instance) -> ()
Caution
Shouldn't be used as it is being called every frame.
Refreshes all the data and visuals of script editor.
Editor:Refresh()UpdateScroll: (self: Editor Instance) -> ()
Caution
Shouldn't be used as it can break script editor.
Changes Y offset of CanvasPosition to the line that player is focused at.
Editor:UpdateScroll()