Help with scripting

How would I make filling this (underlined) out easier as I do not want this line to be extremely long?

1 Like

Something you could replace that line for is the following:

local IsReady = ReadyConfirm.Value
if not IsReady then

Pretty much it just stores the value in a variable, and then instead of doing == false it uses the not feature.

1 Like

Well, you can try to declare a statement as a boolean, like so:

local boolean = (ReadyConfirm.Value == false and PrimeLight.Value == true) 
-- returns a boolean

if boolean then
PrimeButton.Detector.ClickDetector.MaxActivationDistance = 32
end

value == false can be simplified to not value, but the downside to it (if you consider it a downside) is that it will include nil as a false value.

Another way to simplify the following code is with the usage of keyword and, which you can give a statement and then a value:

MaxActivationDistance = not ReadyConfirm.Value and PrimeLight.Value and 32 or 0
1 Like

I am planning to use all those variables above, so I want to simplify it and not make it a extremely long line of values.

1 Like

Here, this should make things more clear.

1 Like

I want to basically get all these easier instead of putting it in one long line of code

2 Likes

I already understood your point, and saying that does not make it any clearer.

It isnt really possible to do that however with variables, and even if It was, It would be way more complicated and slower than just writing an if statement.

With the examples I provided, they should make the proccess much faster, and much more convienient if used correctly

(Could be wrong tho)

1 Like

Sorry, my brain wasn’t braining enough. It’s 4 AM so I apologize if I don’t know what I’m doing. It does seem like a good idea, I’ll try it.

Put all of the variables in a function and check if each variable is valid.
Ex :

local variable_1 = value_1
local variable_2 = value_2

local function bool()
 	if not variable_1 then
		return false
	end

	if not variable_2 then
		return false
	end

	return true
end

if bool() then
	-- do something
end

DO NOT DO THIS AT ALL. PUT EVERY VARIABLE INTO A TABLE AND GO THROUGH THEM. IF ONE OF THEM IS TRUE THEN IT RETURNS FALSE. That is EXTREMELY unoptimized.

You do not know what you are talking about at all.

I wanna be honest with you, if you put all of them into a table and loop through all of them, it’s even more unoptimized and can increase CPU usage. And can also cause lag spikes.

well atleast it would look better than like 48 if statements

Not just look better, but function better and be more friendly to the CPU.