Seems I quoted the wrong thing but;
/run if UnitExists(w)==1 and UnitInRange(w)==1 then if m>=10000 and cd(hs)==0 and sp>=0 then rmt("/cast [@"..w.."] Holy Shock") elseif m>=15000 and mana>0.10 and cd(hl)==0 then rmt("/cast [@"..w.."] Holy Light") elseif m>=35000 and mana>0.5 and cd(dl)==0 then rmt("/cast [@"..w.."] Divine Light") elseif m>=25000 and mana>0.75 then rmt("/cast [@"..w.."] Flash of Light") elseif (m<=0.20 and UnitPowerMax(w)>=75000) and cd(hop)==0 and r(hop,w)==1 and UnitAffectingCombat(w)==1 and not UnitDebuff(w,"Forbearance") and not UnitDebuff(w,"Ice Block") then rmt("/cast [@"..w.."] Hand of Protection") end d,n=0,0; if (n>(npe*0.2) and d/n>5000) and cd(lod)==0 then c(lod) elseif (n>(npe*0.4) and d/n>15000) and cd(hr)==0 then c(hr) elseif (n>(npe*1) and d/n>50000) and cd(goak)==0 then c(goak) elseif (n>(npe*0.6) and d/n>35000) and cd(df)==0 then c(df) elseif m>=20000 and sp>=0 and cd(wog)==0 and (UnitPower("player", 9)>2 or UnitPower("player", 9)==3) then rmt("/cast [@"..w.."] Word of Glory") end end
if m>=10000 and cd(hs)==0 and sp>=0 then rmt("/cast [@"..w.."] Holy Shock")
With this code in the very front of the script m will ALWAYS be either under 10k (do nothing) or greater than 10k (holy shock), of course holy shock has a cooldown, so it will move on to holy light which is next m>15000 but then we have the same problem here so the script will never move on past there.
Now if you do m>15000k and m<35000 (35k for flash of light to heal, and this needs to be done for each heal except the heal that has the most deficient for m). This will make all the healing work but it will never get to the BOP or WOG part of code, since divine light will be the end all. So BOP and WOG either need to be moved to the front and given specific conditions, or moved to a separate /run script.
---------- Post added at 05:19 AM ---------- Previous post was at 05:00 AM ----------
I decided to start the rewrite. 
Not gonna say it's perfect but here it is. Also (see bottom) some code didn't make sense so I left it out.
Code:
#showtooltip Holy Light
/run cd=GetSpellCooldown c=CastSpellByName r=IsSpellInRange sp=GetUnitSpeed("player") mana=UnitPower("player")/UnitPowerMax("player") hs="Holy Shock" hl="Holy Light" dl="Divine Light" fol="Flash of Light" wog="Word of Glory" lod="Light of Dawn" hr="Holy Radiance" goak="Guardian of Ancient Kings" rmt=RunMacroText df="Divine Favor" hop="Hand of Protection"
#SEAL
/run if not IsMounted()==1 and not UnitBuff("player","Seal of Insight") then CastSpellByName("Seal of Insight") end
#BLESSINGS
/run if not IsMounted()==1 and GetSpellCooldown(GetCVar("blessing"))==0 and not UnitBuff("player",GetCVar("blessing")) then CastSpellByName(GetCVar("blessing")) end;
#REBUKE
/run if select(9,UnitCastingInfo('target'))==false and GetSpellCooldown("Rebuke")==0 and IsSpellInRange("Rebuke")==1 then CastSpellByName("Rebuke") end;
/run if select(8,UnitChannelInfo('target'))==false and GetSpellCooldown("Rebuke")==0 and IsSpellInRange("Rebuke")==1 then CastSpellByName("Rebuke") end;
#Divine Shield
/run if UnitHealth("player")/UnitHealthMax("player")<0.10 and GetSpellCooldown("Divine Shield")==0 and IsUsableSpell("Divine Shield")==1 and not UnitDebuff("player", "Forbearance") then CastSpellByName("Divine Shield") end
#Healthstone if needed and Divine Shield on cd
/run if UnitHealth("player")/UnitHealthMax("player")<0.10 and GetSpellCooldown("Divine Shield")>0 and (GetItemCount("Healthstone")==1 and GetItemCooldown(19005)==0) then RunMacroText("/use Healthstone") end
#Divine Protection @ <50% hp
/run if UnitHealth("player")/UnitHealthMax("player")<0.50 and GetSpellCooldown("Divine Protection")==0 then SpellStopCasting() CastSpellByName("Divine Protection") end
#Divine Plea
/run if GetSpellCooldown("Divine Plea")==0 and UnitPower("player")/UnitPowerMax("player")<=0.50 then CastSpellByName("Divine Plea") return end;
#Avenging Wrath if Divine Plea
/run if UnitBuff("player", "Divine Plea") and GetSpellCooldown("Avenging Wrath")==0 not UnitDebuff("player", "Forbearance") then CastSpellByName("Avenging Wrath") end
#Beacon on focus
/run f=0; if UnitExists("focus") and UnitHealth("focus")>1 then for i=1,40 do d={UnitBuff("focus",i)}; if d~=nil and d[1]=="Beacon of Light" and d[8]=="player" and d[7]-GetTime()>=3 then f=1; break end end if f==0 and UnitInRange("focus")==true then RunMacroText("/cast [@focus] Beacon of Light") return end end;
#Judgement focus-target
/run if UnitExists("focustarget") and UnitInRange("focus")==true and UnitAffectingCombat("focus")==1 and GetSpellCooldown("Judgement")==0 then CastSpellByName("Judgement", "focustarget") end
#Get party/raid members
/run t="raid"; nps=1;npe=GetNumRaidMembers();if npe==0 then t="party"; nps=0; npe=GetNumPartyMembers() end;m=0;w=f;for i=nps,npe do if i==0 then tt="player" else tt=t..i end; if UnitExists(tt) and UnitInRange(tt)==true and UnitIsDeadOrGhost(tt)~=1 then a=UnitHealthMax(tt)-UnitHealth(tt);if a>m then m=a w=tt end end end;
#Main healing
/run if UnitExists(w)==1 and UnitInRange(w)==true then if (m<=UnitHealth(w)/UnitHealthMax(w)<=0.2 and UnitPowerMax(w)>=75000) and cd(hop)==0 and r(hop,w)==1 and UnitAffectingCombat(w)==1 and not UnitDebuff(w,"Forbearance") and not UnitDebuff(w,"Ice Block") then rmt("/cast [@"..w.."] Hand of Protection") elseif UnitHealth(w)/UnitHealthMax(w)<=0.15 and mana>0.5 then rmt("/cast [@"..w.."] Flash of Light") elseif m>=10000 and m<=15000 and cd(hs)==0 and sp>=0 then rmt("/cast [@"..w.."] Holy Shock") elseif m>=15000 and m<=35000 and mana>0.10 and cd(hl)==0 then rmt("/cast [@"..w.."] Holy Light") elseif m>=35000 and mana>0.5 and cd(dl)==0 then rmt("/cast [@"..w.."] Divine Light") end end
The WTF code, aside from being broken since I just ripped it out... d,n=0,0 then it goes on to do math on d and n, as if d and n might be values other than 0?
Code:
d,n=0,0; if (n>(npe*0.2) and d/n>5000) and cd(lod)==0 then c(lod) elseif (n>(npe*0.4) and d/n>15000) and cd(hr)==0 then c(hr) elseif (n>(npe*1) and d/n>50000) and cd(goak)==0 then c(goak) elseif (n>(npe*0.6) and d/n>35000) and cd(df)==0 then c(df) elseif m>=20000 and sp>=0 and cd(wog)==0 and (UnitPower("player", 9)>2 or UnitPower("player", 9)==3) then rmt("/cast [@"..w.."] Word of Glory")