ID:145722
 
Code:
        Spell(mob/player/P,mob/monsters/M,list/monstergroup)
P.stage = "Spell Selection"
P.page = 1
MakeArrow(P,1,8)
P.arrows.menu = new/list(3,4)
var/list/pager = new/list()
if(P.page == 1)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else if(P.page == 2)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else if(P.page == 3)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else if(P.page == 4)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else if(P.page == 5)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else
world << "ERROR: PAGE NUMBER INCORRECT! REPORT THIS BUG IMMEDIATLY! BUG ERROR #2!"
return
SpellListing(P,M,monstergroup)
while(!P.arrows.spellchoice)
sleep(1)
for(var/obj/O in P.chooselist)
del(O)
if((pager.len <= 4 && P.arrows.spellchoice == 5) || P.arrows.spellchoice == 9)
if(P.page >= 5)
P.page = 1
else if(!P.spage[P.page])
Battle(P,M,monstergroup)
return
else
if(P.spage[P.page + 1])
P.page ++
else
Battle(P,M,monstergroup)
return
Spell(P,M,monstergroup)
return
var/spell = P.spage[P.page][P.arrows.spellchoice]
AddInfo(P,"Sorry, but you cannot cast","spells yet.")
del(P.arrows)
page = 1
sleep(12)
P.Battle(P,M,monstergroup)
return


Problem description:

Okay, the problem here is simple. Selecting a spell works, and all, but when I try to change spell pages, if I go past the last page, it will just skip my turn, never go back to Battle(blah) and it will go on in the MasterBattle proc where the monsters start attacking. As if it just ended my turn arruptly.

Ok. For starters, the following doesn't make any sense.
            if(P.page == 1)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else if(P.page == 2)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else if(P.page == 3)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else if(P.page == 4)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else if(P.page == 5)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else
world << "ERROR: PAGE NUMBER INCORRECT! REPORT THIS BUG IMMEDIATLY! BUG ERROR #2!"
return


You're doing the exact same thing in every one of those except the last else. So what you want to write is this;
            if(P.page >= 1 && P.page <= 5)
Lister(P,P.spage[P.page])
pager = P.spage[P.page]
else
world << "ERROR: PAGE NUMBER INCORRECT! REPORT THIS BUG IMMEDIATLY! BUG ERROR #2!"
return


Now as for your actual problem, I don't know what's happening inside of these other procs or how this proc is called so I can't follow the actual data 100%, but you return four times. Put an output before each of those returns and then one on the very first line of Battle().
For the outputs in Spell() I recommend just a simple 'return 1', 'return 2' type thing. For the one in Battle() you should output src along with all three arguments.

If I had to guess I'd say you're having problems because either you're calling src.Battle() when you're not meant to, or you're calling P.Battle() at the end instead of src.Battle().
In response to DarkView
First of all, the IF is long like that because I don't have time to spiff it up the first time I'm doing it. It works, that's fine for me till EVERYTHING works. I'll fix it up later. The reason I'm calling P.Battle is because if you reach the end of the spell lists, I want it to go back to the battle choice, where u choose to attack, cast spells, etc. The reason theres a Battle(whateveR) then return is becaause if your going back to Battle, YOU DON'T WANT IT TO GO ON WITH THE SPELL STUFF! The last return I forget why I put it there. The return after the page thing is because IF THERES NO WAY TO SELECT A SPELL, THEN YOU'RE GOING TO BE STUCK AT THE SPELL SELECTION! The return 1/return 2/etc is UNNESSICARY because the spell stuff is going to be continued when I get that working. There's a reason behind all the returns(except the last one, I'll take that one out). The point I'm trying to really CENTER on is the FOLLOWING:
            if((pager.len <= 4 && P.arrows.spellchoice == 5) || P.arrows.spellchoice == 9)
if(P.page >= 5)
P.page = 1
Battle(P,M,monstergroup)
return
else if(!P.spage[P.page])
page = 1
Battle(P,M,monstergroup)
return
else
if(P.spage[P.page + 1])
P.page ++
else
Battle(P,M,monstergroup)
return
Spell(P,M,monstergroup)
return


If I must explain EVERY LINE I will.

The first if - To check if you selected to go to the next page.
The second if - To make sure you aren't going past the max number of pages. if so, make page = 1, call the main Battle again, and return.
The third if - To make sure you aren't going to pages that are non-existant (If there's no page 2, then you shouldn't be able to GO to page 2) Then make page = 1 if it is, go back to battle and return
The else - Go to the next page.

If it gets through that without going back to Battle, you WANT to reload Spell, so that the player can VIEW the next page, then return so it doesn't go on with the rest of the first Spell.

Was it that hard to understand?

In response to Polantaris
Nevermind...I figured it out myself, no thanks to anyone.