ID:1505626
 
Code:
proc
Tree_Grow()
if(Season=="Spring")
for(var/obj/Stump/A)
A.icon='Tileset1.dmi'
A.icon_state="1"
world<<"The trees regrow!"
spawn(10)
Tree_Grow()


Problem description:If I take away if(season=="summer")the code seems to work fine, but when I add the season part in. The code calls, but the icon won't change. I've been at it for an hour or two trying to figure the problem out just can't.

Do you have a procedure to change seasons? You could try set the Season variable to "Spring" by default and run the game.

I'm no genius in DM, but you could also try this instead so you can have multiple seasons in one procedure.

proc/Tree_Change()
if(seasons_on) //once the season has changed we could change this variable to 0. This way we don't have keep looping it.
for(var/obj/stump/A)
if(seasons == "Spring")
//change
if(seasons == "Winter")
//change

else return
Still didn't change the icon on que.
What did you try? Just changing seasons variable to "spring" by default?

How are you calling the procedure to change the trees? My example was just an example by the way.
Default var for season is Winter. Starts there then cycles, and I know. I don't use season_on or off vars so I couldn't really go that route anyway.

But whenever spring does come, the world chat is spammed with "The trees grow again" but the icon won't change. So basically added to the for(var/obj/Stump/A in world) To see if that'd help with a little reading from your example too.
I did this as a test in my game, so the obj paths and names are different. This works changes the tiles at the start but does nothing else.

Note i only change the icon_state, I didn't try change the icon.

Edit: It changes the icon too.

world/New()
..()
spawn(10) Tree_Change()

var
seasons = "spring"

proc
Tree_Change()
for(var/obj/tile/O in world)
if(seasons == "spring")
O.icon = 'tile2.dmi'
O.icon_state = "W"

world << "It's now [seasons]" //To only output once.

obj
tile
icon = 'tile.dmi'
icon_state = "D"
Let me try. Have it setup as seen in the example. Aside from seasons_on. and the vars.
I'm not using seasons_on in this example, left that there by accident. The example I gave by the way, is poor due to not being able to switch seasons at run time.
Could it be that because I have the seasons change periodically it won't change the icon?
If you're changing it every second or so, it's a possibility.
Seasons change every 4-5 months. IG time.
What does your change season code look like?
        if(Month>12)
Year+=1
Month=1
Day=1
Season="Spring"

if(Month>3)
Season="Summer"

if(Month>6)
Season="Fall"

if(Month>9)
Season="Winter"
Is that all of it? Because I don't see you call Tree_Grow() at all.
Made a system where it will change every 20 minutes, not the best, but it was quick.

obj
var
seasons = null
tile
icon = 'tile.dmi'
icon_state = "D"

New()
..()
sleep(20) //just so you can see it change.
src.Seasons()

proc
Seasons()
if(isnull(src.seasons) || src.seasons == "winter") // || = or
src.seasons = "spring"

else if(seasons == "spring")
src.seasons = "winter"

src.Tree_Growth() //change the tree

spawn(1200) src.Seasons() // 20 minutes

Tree_Growth()
if(src.seasons == "spring")
icon = 'tile2.dmi'
icon_state = "W"
return

else if(src.seasons == "winter")
icon = 'tile.dmi'
icon_state = "D"
return
@Lugia..Yeah..I think I should call the proc when seasons change...
Everything here would most likely be better off being global imo.

I suspect the original issue was that you never called Tree_Grow() (which I think might be best off being called with a spawn() because it's recursive) but I'm not sure where Tree_Grow() is called initially so I couldn't tell you.
In response to Lugia319
Lugia319 wrote:
Everything here would most likely be better off being global imo.

I suspect the original issue was that you never called Tree_Grow() (which I think might be best off being called with a spawn() because it's recursive) but I'm not sure where Tree_Grow() is called initially so I couldn't tell you.

I thought so too due to a large amount being changed. I was thinking this whilst I wrote it.