local insideString = (line:match('".+"') or line:match("'.+'") or line:match('%[%[.+%]%]'))
local insideComment = line:match('%-%-.+')
local suffix = CurrentSettings.Suffix
print(suffix) -- clearly says "-"
if command.predicate(line, suffix) and line:reverse():match('.') == suffix and not insideString and not insideComment then
v.Source = table.concat(command.callback(lines, index, line, suffix), '\n')
break
end
modulescript:
local module = {}
local Util = require(script.Parent.Parent.Utilities)
local WAIT_FOR_CHILD = [[%swhile task.wait(%s) do
%s
%send]]
function module.predicate(line: string, suffix: string): boolean
print(line, suffix) -- while- nil
return line:match('while([%p%d]+)' .. suffix) ~= nil
end
function module.callback(source: {string}, index: number, line: string, suffix: string): {string}
local t = line:match('while([%p%d]+)' .. suffix)
local indent = Util.getIndent(line) or ''
source[index] = string.format(WAIT_FOR_CHILD, indent, t, indent, indent)
return source
end
return module
It clearly says “-” in the script, but its nil in the modulescript, anyone know why this is happening and how to fix it?
local LOCAL = false
local Selection = game:GetService('Selection')
local Util = require(script.Utilities)
local Toolbar = plugin:CreateToolbar('Tools')
local ToggleButton = Toolbar:CreateButton('toggle', 'big mistake', 'rbxassetid://6767454852', 'Toggle Script Commands ' .. (LOCAL and 'LOCAL' or ''))
local SettingsButton = Toolbar:CreateButton('settings', 'Configuration', 'rbxassetid://8520704803', 'Settings')
local PluginEnabled = false
local Connections = {}
local PreviousScript = nil
local DefaultSettings = {
['Suffix'] = ';'
}
local CurrentSettings = DefaultSettings
local function outputWarn(str: string, ...)
warn(string.format('[Script Commands] :: ' .. str, ...))
end
local function GetCurrentLineEdited(prev: {string}, source: {string})
local line, index
for i, x in prev do
for j, y in source do
local xmatch, ymatch = Util.ltrim(x), Util.ltrim(y)
if xmatch and ymatch and xmatch ~= ymatch then
line = y
index = j
end
end
end
return line, index
end
local Commands = {}
for _, command in script.Commands:GetChildren() do
table.insert(Commands, require(command))
end
local function execute(v)
local v = Selection:Get()[1]
if not v or not v:IsA('LuaSourceContainer') then
return
end
outputWarn('Listening to "%s"', v:GetFullName())
------------
-- EVENTS --
------------
local previousSource = v.Source
local connection = v:GetPropertyChangedSignal('Source'):Connect(function()
local source = v.Source
local lines = source:split('\n')
local line, index = GetCurrentLineEdited(previousSource:split('\n'), lines)
--print(line, index)
if line then
for _, command in Commands do
-- if predicate and not (inside string)
local insideString = (line:match('".+"') or line:match("'.+'") or line:match('%[%[.+%]%]'))
local insideComment = line:match('%-%-.+')
local suffix = CurrentSettings.Suffix
print(suffix) -- clearly says "-"
if command.predicate(line, suffix) and line:reverse():match('.') == suffix and not insideString and not insideComment then
v.Source = table.concat(command.callback(lines, index, line, suffix), '\n')
break
end
end
end
previousSource = v.Source
end)
table.insert(Connections, connection)
PreviousScript = v
end
ToggleButton.Click:Connect(function()
PluginEnabled = not PluginEnabled
if not PluginEnabled then
outputWarn('Plugin deactivated')
outputWarn('Disconnecting %d connections', #Connections)
for _, connection in ipairs(Connections) do
connection:Disconnect()
end
end
if PluginEnabled then
outputWarn('Plugin activated, listening to selection change.')
execute(Selection:Get()[1])
local connection = Selection.SelectionChanged:Connect(function()
execute(Selection:Get()[1])
end)
table.insert(Connections, connection)
end
end)
-- widget
local WIDGET_INFO = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
false,
false,
200,
300,
150,
150
)
local SettingsWidget = plugin:CreateDockWidgetPluginGui("Settings", WIDGET_INFO)
SettingsWidget.Title = "Settings"
script.Frame.Parent = SettingsWidget
SettingsButton.Click:Connect(function()
SettingsWidget.Enabled = not SettingsWidget.Enabled
end)
for _, v in SettingsWidget.Frame.ScrollingFrame:GetChildren() do
if v:IsA('Frame') then
v.TextBox.FocusLost:Connect(function(enter, input)
local text = v.TextBox.Text:match('[%w%p]+')
if text:match('%d+') then
outputWarn('"%s" cannot be a number', v.Name)
return
end
CurrentSettings[v.Name] = text
v.TextBox.Text = text
outputWarn('%s is now %s', v.Name, text)
end)
end
end
This seems like a good time to use the debugger. You can watch the variables change and follow the code line by line to see where it goes and what it does.
Ok so uh this is kinda weird but the error stopped and i didn’t even know what i did beside changing the current settings to not reference the default settings