Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

how can i make it so an if # statement has to be between two numbers to work?

Asked by 3 years ago

i know the title is worded terribly, but i'm making a shift light for a car, and i set up a separate script to make it "flash" before it hits the optimal shifting point, but i want it to disable once the rpm value reaches a certain point

since i use "if rpm >= 8500 then script.Flash.Disabled = false"

then, i use "if rpm >= 9000 then script.Flash.Disabled = true"

but since the value is also over 8500, it enables the script, but also disables it at the same time is there a way to make it only turn on if its between 8500 and 9000? so then i can use the second if statement that i wrote down to disable it and have it stay disabled, so the light doesnt flash

any help is appreciated!

0
Do you have the if's nested? IAMSEAHAWK 0 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Try this maybe?

if (8500 <= rpm and rpm <= 9000) then
    -- Run your code here
else
    -- Run your code here
end

adding an and to the arguments allows you to add them both to the same if statement. You could also add an 'or' in the same place for other usage. Hope this helps!

Ad
Log in to vote
1
Answered by 3 years ago

Try:

if rpm >= 8500 then 
    script.Flash.Disabled = false
elseif rpm >= 9000 then
    script.Flash.Disabled = true
end

The elseif block only executes if the first one doesn't pass

0
This is pretty much the answer i would go with IAMSEAHAWK 0 — 3y

Answer this question