You are not logged in.

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


This forum will be permanently shut down on Friday 13.07.2018
Please copy or save all important information from old forum before they will be deactivated
We have moved to new board. https://forum.runesofmagic.gameforge.com/Come join us.

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.