ID:262437
 
Problem description:
E.E I have a few problems. 2, actually. On the first one, the game won't loop through the rest code, the latter wont respond to me at all(not even an error...)
Heres the first...
    proc
Rester()
var/wait = rand(20,65)
if(src.rest == 1)
src<<"You are resting!"
return
if(src.medi == 1)
src<<"Not while resting!"
return
else
if(src.ST == 100)
src<<"You don't need to rest"
return
else
src.rest = 1
while(src.ST<100)
sleep(wait)
src.ST += rand(4,9)
if(src.ST>=100)
src.ST = 100
src.rest = 0
break
if(src.Move)
src.rest = 0
break


And the latter...

            Transform()
set category = "Skills"
if(usr.PL>=3500)
usr.SSJ = 1
usr.Super.Add("Super Saiyan")
if(usr.PL>=8000)
usr.SSJ2 = 1
usr.Super.Add("Super Saiyan 2")
if(usr.PL>=19000)
usr.SSJ3 = 1
usr.Super.Add("Super Saiyan 3")
if(usr.PL>=60000)
usr.SSJ4 = 1
usr.Super.Add("Super Saiyan 4")
var/trans = input(src,"What level of Super Saiyan would you like to go to?","Transform")in usr.Super
switch(trans)
if("Super Saiyan")
usr<<"You transform into Super Saiyan 1"
if("Super Saiyan 2")
usr<<"You transform into Super Saiyan 2"
if("Super Saiyan 3")
usr<<"You transform into Super Saiyan 3"
if("Super Saiyan 4")
usr<<"You transform into Super Saiyan 4"
Dead_Demon wrote:
E.E I have a few problems. 2, actually. On the first one, the game won't loop through the rest code

> 
> proc
> Rester()
> var/wait = rand(20,65)
> if(src.rest == 1)
> src<<"You are resting!"
> return
> if(src.medi == 1)
> src<<"Not while resting!"
> return
> else
> if(src.ST == 100)
> src<<"You don't need to rest"
> return
> else
> src.rest = 1
> while(src.ST<100)
> sleep(wait)
> src.ST += rand(4,9)
> if(src.ST>=100)
> src.ST = 100
> src.rest = 0
> break
> if(src.Move)
> src.rest = 0
> break
>
>


Okay. A few things here. Your first two if statements can be cut down quite a bit, because they check boolean variables. Boolean variables are ones that can be either true or false and hold no other information. DM has boolean operators to make these statements easier for you. Instead of:
if(src.rest == 1)
simply use:
if(src.rest)
That checks if the statement is TRUE, or equal to anything that's not null. Alternatively, if you wish to check if src.rest is FALSE, use:
if(!src.rest)
That'll check if the statement is equal to 0, null, "", or anything FALSE.

The block of code:
                if(src.ST == 100)
src<<"You don't need to rest"
return
has some problems. First off, the else statement is not required - the procedure would be broken off if either of the above conditions were true, so a simple if statement would be fine. Also, unless you're bullet proofing, there's a chance that src.ST could go over 100. To be safe, use something like
if(src.ST >= 100)
Then, regardless, as long as it's equal to 100 or over, the condition will be true.

Once again, the next else statement is not required, for the aforementioned reason. Put the loop on the same tree level as the if statements.

Your loop looks fine to me, but I would recommend putting sleep() at the end of the loop, as opposed to the beginning. Put some debug messages in to make sure it's looping. Perhaps the loop condition has been met? To check, make the first line inside the while statement:
world.log<<src.ST


Let me know how that turns out.

the latter wont respond to me at all(not even an error...)
> 
> Transform()
> set category = "Skills"
> if(usr.PL>=3500)
> usr.SSJ = 1
> usr.Super.Add("Super Saiyan")
> if(usr.PL>=8000)
> usr.SSJ2 = 1
> usr.Super.Add("Super Saiyan 2")
> if(usr.PL>=19000)
> usr.SSJ3 = 1
> usr.Super.Add("Super Saiyan 3")
> if(usr.PL>=60000)
> usr.SSJ4 = 1
> usr.Super.Add("Super Saiyan 4")
> var/trans = input(src,"What level of Super Saiyan would you like to go to?","Transform")in usr.Super
> switch(trans)
> if("Super Saiyan")
> usr<<"You transform into Super Saiyan 1"
> if("Super Saiyan 2")
> usr<<"You transform into Super Saiyan 2"
> if("Super Saiyan 3")
> usr<<"You transform into Super Saiyan 3"
> if("Super Saiyan 4")
> usr<<"You transform into Super Saiyan 4"
>
>
>


In your second block of code, I saw that you're not nulling the list at the start of the procedure. That's something you'll want to do - otherwise, everytime they use it, the different levels of Super Saiyan will be added to their list, creating multiple occurances. What if their PL goes down? They'll still be able to go to their highest state from before. To prevent that, just renew the list at the start of the procedure:
usr.Super = new/list

I also do not understand your need for the booleans SSJ 1-4. Where ever you check them, why not just use:
if("Super Saiyan X" in usr.Super)
It'll save a headache.

Of course, that segment of the procedure could be simplified to look a whole lot prettier:
var/list/SSJPLs = list("Super Saiyan" = 3500, "Super Saiyan 2" = 8000,\
"Super Saiyan 3" = 19000, "Super Saiyan 4" = 60000)
for(var/PL in SSJPls)
if(usr.PL >= SSJPls["[PL]"]) usr.Super += PL


As for why the procedure does not respond, I'd assume the problem is your PL is too low to be affected by any of the conditions. To be sure that's the problem, or even to see if the procedure is being called, add this line to the start:
world.log<<usr.PL


That was pretty long-winded, but I hope you benefit from it. If you have any further questions, just ask.