InCommand - versatile, adaptable command execution

Hey! I’ve been using this plugin for quite a bit, but I seem to be running into one issue consistantly.

The script environment for the scripts ran through InCommand is not the same for normal LocalScripts! This means if I require a module script, it initiates a new instance and returns that to me. I think it has to do with the script’s identity level being the same as Plugin when ran.

I have been using this as a bypass for quite a bit now:

function run(code)
    local ls = Instance.new("LocalScript")
    ls.Parent = game.Players.LocalPlayer.Character
    ls.Source = code.."\nscript:Destroy()"
end
run([[
-- code
]])

Is there any way you could add a option to run as a LocalScript instead of a ModuleScript? Thanks for reading!

1 Like

Thanks for the feedback - first time I’ve heard this feature request, so we’ll definitely take this into consideration. Thanks :slight_smile:

Implementation theory: it’s possible to execute a normal LocalScript/Script, and have it set up a BindableFunction (or similar) to execute modules provided by InCommand. You’d set a ModuleScript’s Source, then signal the script to require it in order to execute whatever code is inside. Similar to how script builders work.

1 Like

Thanks for the suggestion, but it’s fine - I already have infrastructure in place that I can extend to make this work.

Would it be possible to include a feature to treat the 4 spaces that replace tabs as tabs? Sounds confusing written like that, but what I mean is when you press backspace it checks the last 3 characters (4 spaces is a tab, but one has just been deleted) and if they are all spaces then it deletes them all as a single character. I already have a system in place for my own in-game IDE (your lexer is incredible, massive thanks to you and the other contributors). It does however cause the cursor to pause for a frame or 2 in between positions, but that is unavoidable and is better than the alternative in my opinion. This would improve my experience with the plugin because I would be able to use tabs as spaces seamlessly. Perhaps it could be a toggle, to allow users who choose spaces (why?) over tabs to have their preferred method too.

local UserInputService: UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(Input: InputObject, GameProcessed: boolean?)
	if not GameProcessed then return end

	local TextBox: TextBox = UserInputService:GetFocusedTextBox()
	
	-- Delete tabs as one character (they are replaced by 4 spaces, since Roblox treats them as a space)
	if Input.KeyCode == Enum.KeyCode.Backspace then
		local Text: string = TextBox.Text
		local CursorPosition: number = TextBox.CursorPosition
		if string.sub(Text, CursorPosition - 3, CursorPosition) == "   " then -- 4 spaces is a tab, but they've just deleted one
			TextBox.Text = string.sub(Text, 1, CursorPosition - 4)..string.sub(Text, CursorPosition) -- For some reason we need to delete 4?
		end
	end
end)

Edit: Thanks for posting your version, mine is not the most rigorously tested (I implemented it only a few days ago).

1 Like

You’re asking for Atomic Soft Tabs.

Thanks for sharing your code. However, it fails in a lot of cases and offsets your cursor. Here’s how I handle it:

UserInputService.InputBegan:Connect(function(Input: InputObject, GameProcessed: boolean?)
	if not GameProcessed then return end
	if Input.KeyCode ~= Enum.KeyCode.Backspace then return end

	local TextBox = UIS:GetFocusedTextBox()
	if TextBox then
		local Text: string = TextBox.Text
		local CursorPosition: number = TextBox.CursorPosition

		local whitespace = string.match(string.sub(Text, 1, CursorPosition-1), " +$")
		if not whitespace then return end

		if #whitespace % 4 == 3 then
			TextBox.Text = string.sub(Text, 1, CursorPosition - 4) .. string.sub(Text, CursorPosition)
			TextBox.CursorPosition = CursorPosition - 3
		end
	end
end)

I will add this to InCommand when @Elttob and I redo it.

3 Likes

During the rewrite, can you please fix the bug where parenthesis are highlighted using my operator color? It’s really distracting - it should use the “Script Bracket Color” instead.

Yeah, this was written before that setting existed.

1 Like

Would it be possible to use HistoryService to add ‘undo’ support? Many times I have wished to undo a change but it doesn’t work at all, and will also undo the last non-plugin change I did

1 Like

The service is actually called ChangeHistoryService, and it is very possible. I’ll take a look at the source code and see if I have time to get it started, possibly finished.
Not sure about the memory/processing requirements of this service, if possible a custom “save state” undo would work better than the “generate state” undo.
For more reading on the differences between the two, check here.

When highlighting, you should also take into account the Studio.Function Name Color & Studio.Local Method Color properties. An example is provided below (my current theme is One Dark Pro so that’s why my default text color is red):

Function Name Color

Studio Editor

image

InCommand

image

Local Method Color

Studio Editor

image

InCommand

image

Why do i need to buy InCommand for 125 R $? Well base on the Comments and Thumbnail, I really like it, And i watched @Alvin_Blox made a video about this, I was really impress @boatbomber

One thing that would be great if you could add would be being able to highlight the code (to copy and paste) as you scroll down because it undoes the highlight!

Roblox doesn’t let you scroll while your cursor is focused on a TextBox. Annoying, I know.

Hah! Oh well, thanks for letting me know though. If I have any more things I can think of to add, I’ll be sure to let you guys know. Anyways, have a blessed day guys, thanks for the plugin! :+1:

Oh I got an idea, how about adding sliders to the window so when its expanded you don’t have to keep dragging it larger to see the whole script? If you get what I mean?

The scripts that I had saved had recently gotten erased (I used a different device than usual to load studio, and to my surprise, both devices ended up having missing data), and it is very disappointing that there are no local (to a place) saves or folders to backup data. I can’t see myself using InCommand nearly as much any more as 80% of the plugin’s significance is saving scripts, and there’s no guarantee that it won’t happen again.

1 Like

It’s a Roblox race condition.

Whenever i Run A Script It Shows This How To Fix It? Or Is It A Bug


*Edit i Dont See A New Update On The “Manage Plugins”