Built-in function color "self" in scripts

When I mean built-in function color, I mean this (im using the default settings/colors)
image
image
image
You get the idea.

Making self color like this (like :remove()) is pretty minor but I just feel it’d add a bit to the interface when scripting. I’m not a big OOP fan when it comes to Lua but in JS, the equivalent of self is this. But this in coding interfaces like Notepad++ in JavaScript is auto colored like that. I’d be skeptical about why ROBLOX studio hasn’t added this into its database yet. ¯\_(ツ)_/¯

21 Likes

This is kinda accidental because of table.remove.

4 Likes

I agree. I think it would also be nice if metamethod names such as __add and __concat were colored like built-in functions too.

3 Likes

Oh? That’s why, that’s actually kinda funny.

Wait is self even used in Roblox Lua? I tried it and it doesn’t work…

1 Like

@Mr1Vgy it is if you invoke a function in a table as a method, ie

local tbl = {}
tbl.internalSafeValue = 0

function tbl:incrementSafeValue()
– santize inputs here, ensure validity
self.internalSafeValue = self.internalSafeValue + 1
end

where within the function tbl:incrementSafeValue() self refers automatically to the table the function “incrementSafeValue” is found within. It’s a bit more technical but that’s the simple version. This is useful for creating psuedo class inheritance where we have classes that spawn helper classes, and we want one function to handle everything rather than creating multiple functions for every helper.

3 Likes

Oh wow cool, I didn’t know that, thanks!
Also I would totally support this.

I agree. All other Lua syntax highlighers I’ve used recognize self as a keyword and colorize it differently.

2 Likes

I agree, all major syntax highlighters do this, except the one in ROBLOX Studio :frowning:

Hm. Assuming no one has any objections internally (and I doubt they would), I’m gonna make this happen. Even we use “self” extensively in our internal Lua code.

17 Likes

Oh my god yes, thank you so much.

Now that I know what this is I support it, woot and thanks!

1 Like

Did someone say “shipped”?

SHIPPED

13 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.