Return doesn't actually return?

duggold
I was spinning my wheels for a while and finally figured out the problem is the return command doesn't actually exit the function. This seems pretty counter-intuitive. Why was this done and how CAN I exit a function prematurely?

Pertex
duggold wrote:...how CAN I exit a function prematurely?

You can't do it at the moment.

sgreig
A clever programmer friend of mine says it's possible to fudge a break command in a language that doesn't have any by modifying the iterator variable in the loop. So if you have a script that loops until the variable i = 10 or until another condition is met, simply add code to the section where the condition is met that changes i to 20 and it will exit the loop prematurely.

Not sure if I explained it in a way that makes sense, but I've used it since his suggestion and it works well.

duggold
Yes, the issue is it's not a loop. I have a check at the beginning of the function to see if there's anything in the room. If not, I wanted to simply return. I restructured it to just use else commands etc. to just skip all the code. Just seems inefficient and really odd that return really doesn't return.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums