You are not logged in.

Applications: [GameMaster: OPEN] | [Volunteer Testers: OPEN]


/!\ We have moved to a new board. Come join us. This board is now in "archive" (read-only mode). /!\

Dear visitor, welcome to Runes of Magic US / AU. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, September 26th 2014, 12:47am

Stopping a script before the end

If for example you have a large script doing many things and you want it to exit before reaching the end of the function what is the correct way of doing that.

A lazy healing script im playing with will heal raid 1-12, if anyone dies it prints to party who died (for the leroy tank who tears off without the healer LOL), and when combat ends it begins resing. So when it begins resing I don't want the function to continue cause later in the script it will retarget the tank.

Do I use Break or Return or some other command.

2

Friday, September 26th 2014, 3:16am

break exits loops (while/repeat) and return exits functions.

eg

Source code

1
2
3
4
5
6
7
8
9
10
11
function checkDead()
  while true do
    if targetDead then
      break
    elseif targetAggro then
      return
    end
    targetNextPlayer()
  end
  resPlayer()
end


So if the target is dead it'll break loop and res, else if target has aggro on something it'll exit function so you can run another to deal with it.

all just made up functions ofc xD And could be totally wrong as well :D
Cammo (82 M/82 W/82 R) 116,147 unbuffed Matk :D (95k pa - r/m)
Livia (82 P/77 K/75 S) wisdom O.o wtf is that...
~~ retired - Thanks to gameforge for that. ~~

3

Friday, September 26th 2014, 6:35am

Chears, using return did what I was after.