ID:146791
 
Code:
mob
forbidden
verb
superclone()
var/input = input("How much Chakra do you want to put in?", "Chakra Input") as num
if((input >= 100000)&&(input<=usr.chakra))
usr<<"<b>You put all the chakra you can into the move</b>"
usr.chakra -= 100000
usr.clones = 100
if(input>=usr.chakra)
usr<<"<b>You do not have this much chakra to put into this move</b>"
return
if (input <<1000)
usr.chakra -= input
usr.cloness = 1
if (input <= 0)
usr<< "<b>You have put no chakra into this move</b>"
return
else
usr.chakra -= input
usr.clones = round(input/1000)
overlays += 'smoke.dmi'
spawn(8)
overlays -= 'smoke.dmi'
for(clones,clones<1,clones--)
var/mob/clone/M
M = new/mob/clones()
M.maxhealth = usr.maxhealth/10
M.health = M.maxhealth
M.stamina = usr.maxstamina
M.maxstamina = usr.maxstamina
M.maxchakra = usr.maxchakra
M.chakra = M.maxchakra/2
M.name = usr.name
M.icon = usr.icon
usr.random = rand(-5,5)
usr.random2 = rand(-5,5)
M.loc = locate(usr.x+random, usr.y+random2, usr.z)


Problem description:
I know the clone should be produced as I have a single clone verb but the for loop doesnt run, I tried to use a while loop but they never seemed to like me. The for loops skips completely but the smoke is added before. Can someone help me find why the loop doesn't run at all please
Ramini
Ramini wrote:
Code:
> mob
> forbidden
> verb
> superclone()
> if (input <<1000)
> usr.chakra -= input
> usr.cloness = 1
>


Your if() statement is incorrect. it should be if(input < 1000). The << operator is for outputting something, or bitshifting.

~X
In response to Xooxer
Xooxer wrote:
Ramini wrote:
Code:
> > mob
> > forbidden
> > verb
> > superclone()
> > if (input <<1000)
> > usr.chakra -= input
> > usr.cloness = 1
> >

~X

It also looks like clones might be misspelled.
In response to Neo Skye
Ah thanks didn't notice that, I thought I had to use double operators in if statements, I will try it out now, to be honest its not called clones in the program I just change a few variable names to vaguely conceal the exact topic :-P Just so noone will end up with exactly the same code as me in the end even if its just the variable names different.
In response to Ramini
As seems to happen nobody actually replied to help with my real problem so I had to completely change the way I looked at the problem and more or less change the way the move is set out :-(
In response to Ramini
this bugged me:
for(clones,clones<1,clones--)


if we say that (for the sake of argument) clones=2 (or any number higher than 0) someplace earlier in the routine, then the for loop fails the second condition, the clones < 2. replacing clones with 8 in your code, we get:
for( initializer (starting value for the loop) is 8, is 8 less than 1 ? , if true, subtract 1 from 8 )

the loop is skipped because the test always fails unless clones are less than one to begin with.

sorry it's late, but hope it helps where the logic failed.
In response to digitalmouse
After reviewing the proc and what it seems he's trying to do with it, I've come up with:

mob
forbidden
verb
superclone()
var/input = input("How much Chakra do you want to put in?", "Chakra Input") as num || null
if (!input) return

if(input <= 0)
usr<< "<b>You have put no chakra into this move</b>"
return

if((input >= 100000)&&(input<=usr.chakra))
usr<<"<b>You put all the chakra you can into the move</b>"
usr.chakra -= 100000
usr.clones = 100

if(input>=usr.chakra)
usr<<"<b>You do not have this much chakra to put into this move</b>"
return

if (input < 1000)
usr.chakra -= input
usr.cloness = 1

else
usr.chakra -= input
usr.clones = round(input/1000)

overlays += 'smoke.dmi'
spawn(8)
overlays -= 'smoke.dmi'

for(clones,clones>=1,clones--)
var/mob/clone/M
M = new/mob/clones()

M.maxhealth = usr.maxhealth/10
M.health = M.maxhealth
M.stamina = usr.maxstamina
M.maxstamina = usr.maxstamina
M.maxchakra = usr.maxchakra
M.chakra = M.maxchakra/2
M.name = usr.name
M.icon = usr.icon

usr.random = rand(-5,5)
usr.random2 = rand(-5,5)

M.loc = locate(usr.x+random, usr.y+random2, usr.z)


Some of the structure seemed off, and a few parts needed changing, like the for loop. It was checking to see if clones was less than 1, and reducing clones if true. This would have caused an infinite loop if it ever worked. The reason it was not working is because of the last else. It was reseting clones to input/1000 which would probably have rounded out to 0. Now it only executes that else if the input range is between 1000 and 99999. Might work.

~X
In response to Xooxer
*grin* Thanks alot, I thought the condition in the for statement was when to exit the loop (Like a repeat-until in pascal, my first coding language). Sorry about complaining its just everytime I post I seem to get someone correcting some small error in the code that I would notice easily once the code was running and nobody actually points out what is stopping the code itself compiling :-)
Ramini