Is there something i can do to get a warning of unused varibles?

tried googling and there isnt anything about that
i like that feature from the rust compiler

1 Like

if its a value thats nil then you can

put all your variables into a table then do

for i, v in pairs(yourtable) do
	if not v then
		warn(tostring(v).." is unused")
	end
end

example of an unused variable here:

local variable

Why would you have unused variables… do you add variables first and then decide what to do with them?

I cant speak on behave of them, but I can say that this feature could prove useful.

I usually make big complicated systems, and as I rework certain things and make changes, some variables are no longer used, but since I have so many values its hard to tell without going through the entire system which ones are no longer in use.

In short there are many scenarios where this would prove useful, way more than we can think of, so it is very much possible for unused variables to exist without doing what you mentioned.

4 Likes

Currently, there’s no way to enable unused variable warnings in the script editor. You can get this behavior if you use external IDEs, but it’s not worth using in my opinion.

1 Like

This wouldn’t work.
If the variable is false, it’ll return that its not used.

Alternatively, if a key in a table is set to nil, it just removes the key.
image

1 Like

You can use ROJO, this will allow you to clean your code in visual studio

yeah
thats exactly why i was asking

1 Like

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