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

How could i end a function in different places?

Asked by 9 years ago

Let me explain better, I have a shop script that uses more than one currency. if the player has at least the required amount of one of the currencies, then the item is bought.

Ex. The item costs 5 burgers and 3 kittens, if I have 5 burgers OR 3 kittens, the transaction is made. is there a function in lua that lets you break out of a function?

if currency1.Value > num then
    --subtract item
else
    --break out of function
end

1 answer

Log in to vote
0
Answered by 9 years ago

Make the function return

If you need to come out of a function immediately, you can use the return keyword to do it.

The equivalent keyword for escaping loops is break

Ad

Answer this question