ID:26984
 
My newly-written line of code died! Someone help me please.
var/season

world
New()
if(season==null)
season = "Spring"
for()
sleep(60)
if(season=="Spring")
season = "Summer"
if(season=="Summer")
season = "Fall"
if(season=="Fall")
season = "Winter"
if(season=="Winter")
season = "Spring"
world << "It is now [season]"
if(season=="Spring")
world << "The frozen ice melts."
for(var/turf/frozenwater/M in world)
M.density = 1
M.icon = 'Water.dmi'
M.name = "Water"
if(season=="Fall")
world << "The frozen ice freezes over again"
for(var/turf/frozenwater/O in world)
O.density = 0
O.icon = 'FrozenWater.dmi'
O.name = "Frozen Water"

No matter what, it keeps saying its Spring.(I have the timer set so low for testing) When its supposed to be summer, its spring. SPRING SPRING SPRING.. It just won't change! Help please..

EDIT: Found what I did wrong. Works like a charm now. THANKS ACE!
<code> if(season=="Spring") season = "Summer" if(season=="Summer") season = "Fall" if(season=="Fall") season = "Winter" if(season=="Winter") season = "Spring"</code>

You are setting it to Summer-Fall(cough autumn)-winter-spring. You just set the variable to the next one and then have an If statement asking if its the same value as the one you've just changed. :p

Hence by the time it gets to the next line, your back at Spring.
*Doh* Now I see it. I wondered why I was thinking of return procs for some reason, even know I didn't need to use one I basically needed to do something similar.

Just need to use a Goto proc and make a marker after those if()s..

Thanks Ace.
use else if() instead of just if()
Mechana2412 wrote:
*Doh* Now I see it. I wondered why I was thinking of return procs for some reason, even know I didn't need to use one I basically needed to do something similar.

Just need to use a Goto proc and make a marker after those if()s..

Thanks Ace.

Do not use gotos. That is perhaps the most helpful piece of advice I could ever give you. Gotos are evil. EVIL!

Also, it shouldn't use 'return', or your proc won't restart itself. Make it restart itself when it hits that season-change.
USE ELSE IF()