ID:1316294
 
(See the best response by Kaiochao.)
Code:
obj 
FinishCharCreate
Click()
if(usr.sel && istext(usr.sel) && !usr.FIN)
usr.FIN=1
switch(alert(usr,"You sure your done this stage of character creation?","Finished?","Yes","No"))
if("Yes")
if(!usr.client || !(usr.sel && istext(usr.sel))) return


It says infinite looping is suspected, but from reading other posts I can pretty much conclude that set background=1 or world.loop_checks=0 is a bad fix for this. Still a newbie at this so try not to be too harsh :P

Best response
That's some nice code you have there.

So where's the code causing the problem?
This is what shows up in when I make a character:
Infinite loop suspected--switching proc to background. If it is not an infinite loop, either do 'set background=1' or set world.loop_checks=o.
proc name: Click (/obj/FinishCharCreate/Click)
source file: Creation.dm, 165
usr: Youtopia (/mob/human/player)
src: FinishCharCreate (/obj/FinishCharCreate)
call stack:
FinishCharCreate (/obj/FinishCharCreate): Click(Creation2 (16,1,2) (/turf/Creation2)|
Are you sure you posted the entire /obj/FinishCharCreate/Click() proc? It looks incomplete.
It's pretty long, but here:
FinishCharCreate
Click()
if(usr.sel && istext(usr.sel) && !usr.FIN)
usr.FIN=1
switch(alert(usr,"You sure your done this stage of character creation?","Finished?","Yes","No"))
if("Yes")
if(!usr.client || !(usr.sel && istext(usr.sel))) return
if(usr.cVillage=="Leaf")
usr.faction=leaf_faction
usr<<"You were created in Konoha"
else if(usr.cVillage=="Sand")
usr.faction=sand_faction
usr<<"You were created in Suna"
else if(usr.cVillage=="Kiri")
usr.faction=mist_faction
usr<<"You were created in Kiri"
else if(usr.cVillage=="Iwa")
usr.faction=rock_faction
usr<<"You were created in Iwa"
else if(usr.cVillage=="Kumo")
usr.faction=cloud_faction
usr<<"You were created in Kumo"
else
usr.FIN=0
usr<<"You must choose a village."
return

name:
var/surname
var/firstname
switch(usr.sel)
if("Kaguya")
surname="Kaguya"
if("Haku")
surname="Yuki"
if("Uchiha")
surname="Uchiha"
if("Nara")
surname="Nara"
if("Hyuuga")
surname="Hyuuga"
if("Akimichi")
surname="Akimichi"
if("Aburame")
surname="Aburame"
if("Capacity")
surname=""
usr.icon='base_shark.dmi'
usr<<"You were born with Shark Skin - Capacity Exlusive"
usr.icon_name="base_shark"
if("Jashin")
surname=""
new/obj/items/weapons/melee/sword/HidanSword(usr)
if("Spider")
surname=""
new/obj/items/weapons/bow/War_Bow(usr)
if("Wood")
surname="Senju"
usr.name_selecting = 1
var/name = input(usr, "Enter your name. Please do not name yourself after Naruto characters.") as text
name = Replace_All(name, chat_filter)
if(!usr.client) return
var/space_pos = findtext(name, " ")
if(space_pos && !surname)
surname = copytext(name, 1, space_pos)
firstname = copytext(name, space_pos+1)
else
firstname = name

if(surname)
surname = Replace(surname, " ", "")
surname = world.Name_Correct(surname)
else
surname = ""

firstname = Replace(firstname, " ", "")
firstname = world.Name_Correct(firstname)
usr.surname=surname
usr.firstname=firstname
if(length(surname))
usr.name="[usr.surname] [usr.firstname]"
else
usr.name="[usr.firstname]"
if(!usr.client) return

if(world.NameCheck(usr.name)&&usr.client)
if(!usr || !usr.client) return
alert(usr,"That name is taken, please enter a different one.")
if(!usr || !usr.client) return
usr.name="Nameless"
usr.surname=0


goto name
if((world.Name_No_Good(usr.name))&&usr.client)
if(!usr || !usr.client) return
alert(usr,"Names must be shorter than 20 characters, and start with a capital letter.")
if(!usr || !usr.client) return
usr.name="Nameless"
usr.surname=0

goto name

if(!usr.name)
usr.surname=0
goto name

Names.Add(usr.name)
usr.realname=usr.name

usr.clan = usr.sel

usr:AddSkill(KAWARIMI)
usr:AddSkill(WINDMILL_SHURIKEN)
usr:AddSkill(SHUNSHIN)
usr:AddSkill(BUNSHIN)
usr:AddSkill(HENGE)
usr:AddSkill(EXPLODING_KUNAI)
usr:AddSkill(EXPLODING_NOTE)

switch(usr.clan)
if("Sand Control")
usr:AddSkill(SAND_SUMMON)
usr:AddSkill(SAND_UNSUMMON)
if("Aburame")
usr:AddSkill(BUG_SUMMONING)
if("Scavenger")
usr:AddSkill(HEART_EXTRACTION)
if("Uchiha")
var/eye=pick("Failed","Succeeded")
switch(eye)
if("Failed")
usr << "You were not born with the potential to gain Eternal Light!"
if("Succeeded")
usr:AddSkill(TAKE_EYE)
usr:AddSkill(TAKE_EMS)
usr << "You were born with the ability to obtain the Eternal Light!"
usr << "You will only be able to use thise jutsu once.The higher the faction points the higher the chance you will be able to obtain Eternal Light"
usr << "I would recommend you use the jutsu when you have 50+ faction points"
usr << "Once you get 200 kills and take someones EMS you recieve Rinnegan"

usr:RefreshSkillList()
usr.body=Req2Level(usr.blevel)+92
usr.DoneCreate()
sleep(30)
var/level = 90
while(usr && usr.blevel < level)
usr.body=Req2Level(usr.blevel)+1
usr:bodycheck()
sleep(2)
if(usr.clan=="Capacity")
usr.icon='base_shark.dmi'

if(usr.initialized)
usr.levelpoints=6

world.SaveMob(usr,usr.client)

usr.faction.AddMember(usr)

usr.Refresh_Faction_Verbs()
usr.Refresh_Squad_Verbs()
if(usr.clan=="Capacity")
usr.icon='base_shark.dmi'
usr.name_selecting = 0
spawn(10)usr.Refresh_Mouse()
else
usr.FIN = 0
else
usr.FIN = 0
else
usr<<"You need to pick both a village and a Clan/Trait First!"
Rip.
while(usr && usr.blevel < level)
usr.body=Req2Level(usr.blevel)+1
usr:bodycheck()
sleep(2)

Indentation error? Doesn't seem like the sleep() is within your while loop.
indenting it gives me errors
Don't indent it the way I did. I merely copied and pasted yours. Just make sure your sleep(2) is inside of the while loop, rather than flush with it.
Gokussj99 taught me to use spawn instead of sleep to make loops.
                        while(usr && usr.blevel < level)
usr.body=Req2Level(usr.blevel)+1
usr:bodycheck()
sleep(2)

code\game\Creation.dm:168:error: proc definition not allowed inside another proc
code\game\Creation.dm:191:error: unbalanced }
but when i leave it flushed there's no errors :/
In response to Youtopia
Youtopia wrote:
                        while(usr && usr.blevel < level)
> usr.body=Req2Level(usr.blevel)+1
> usr:bodycheck()
> sleep(2)

code\game\Creation.dm:168:error: proc definition not allowed inside another proc
code\game\Creation.dm:191:error: unbalanced }
but when i leave it flushed there's no errors :/

Change it to spawn.
In response to -._.DreamBunny._.-
That spawn will halt nothing unless there is something within it.
I'm trying to make it so that it doesn't loop, because the loops crash the server D:
In response to Youtopia
Youtopia wrote:
I'm trying to make it so that it doesn't loop, because the loops crash the server D:

If you put it in spawn it doesn't crash the sever only sleep i heard?
Don't use spawn() within a loop. Spawn the whole loop and then sleep within it. Spawning within the loop will literally clone the entire proc each time the loop iterates.

Spawn has nasty overheads and is one of the worst procs included with BYOND. If you can get away with it at all, never use spawn(). I would instead suggest set waitfor = 0 and sleep(). Read the red book for more info on set waitfor.
In response to -._.DreamBunny._.-
With a name like "Gokussj9", why would you ever take their advice regarding programming? He obviously has no idea how sleep() and spawn() work at all.

@Youtopia: don't ever use colons (:) like that. It's just malpractice. Use periods (.) because you should never have to use a colon like that.
In response to Spunky_Girl
Spunky_Girl wrote:
With a name like "Gokussj9", why would you ever take their advice regarding programming? He obviously has no idea how sleep() and spawn() work at all.

@Youtopia: don't ever use colons (:) like that. It's just malpractice. Use periods (.) because you should never have to use a colon like that.

Spunky_Girl no offence i think you need to shut up. It's not about the the name it's about the skill so next time you talk make sure it's something smart.
In response to Spunky_Girl
Spunky_Girl wrote:
With a name like "Gokussj9", why would you ever take their advice regarding programming? He obviously has no idea how sleep() and spawn() work at all.

Also, his name is gokussj99
@DreamBunny:
Well from what you said, spunkygirl's conclusion, although prejudicial is still correct. Perhaps Gokussj99 is a great programmer but what you presented as his lessons are not.

You may put spawn before while() so that the while doesn't interfere/delay other things- but it wouldn't "make" the loop. Sleep()'s are often used in loops so they don't loop extremely fast (with out delay but not technically instant).


OT:
The initial issue of this thread was the fact he indented wrong and had a while() running with not only no delay but nothing with in it.

while(usr && usr.blevel < level)
usr.body=Req2Level(usr.blevel)+1
usr:bodycheck()
sleep(2)


while(usr && usr.blevel < level)
usr.body=Req2Level(usr.blevel)+1
usr:bodycheck()
sleep(2)


The error about procs being inside of other procs is because of the way he indented sleep and not the other stuff. All he has to do is indent the two lines above that to include those three in the loop.

Aside from getting the code to run with out runtime errors, this whole thing is really poorly done. If the OP wants to know why and how he could improve feel free to ask questions.
Page: 1 2 3