SOLVED Change object variables while they dont exist

minitaba

Member
hey, its me again with a problem haha

I am making a game with gardening features, and the plants work similar to the classic well known farming games.
You plant your seed, water it and it grows a little every day / few days and if you dont water them they dont grow and finally you harvest your crobs.

I am almost finished with the growing- and harvesting-system and now I came across a problem I can not find out how to fix.

When i leave the farm (room) the crops data gewts saved in a DS and when Entering the room they come back. I included the Sprites below them is they are watered or not (the soil just appears darker then) and the "watered" status of the crop as well.
watered = true; switches to =false at midnight, when a new day starts (you have to water them daily) which works as well.

But here is the issue:
When I am at the farm and the time goes by, everything works fine, but how can this work when I am not in the same room? The Age / Growstage of the plant is safed on, lets say, day 1, and i come back at day 2, the plant should have grown / have gone to a new growing Stage, but i can just use the data stored in the DS and dont change the plant when it doesnt exist.

I tried to add
Code:
if (daywhensafed < today) {daysOld += 1} to the Plant instances
but this did not work at all.

My saving script for the crops:
Code:
Anyone has an idea how to realize a working system to upgrade my growStage while the instances dont exist?


Thanks a lot : )
 
Last edited:

Mr Magnus

Viking King
You can not interact with instances that do not exist.

Usually how this is solved is that upon re-entering the room you check how many days have passed and *then* you perform the required updates. After all, it doesn't matter to the user if the plants have grown or not until they look at them.
 

minitaba

Member
You can not interact with instances that do not exist.

Usually how this is solved is that upon re-entering the room you check how many days have passed and *then* you perform the required updates. After all, it doesn't matter to the user if the plants have grown or not until they look at them.
I tried that before but I guess I did something wrong.
Now I added this to my Respawn event:
Code:
    if(daycycle.day > argument5){
    inst.daysOld = argument3 + 1} else {inst.daysOld = argument3;}

And it works great. thanks a lot, sometimes it just helps to write it down, read some suggestions and think for a minute lol
 

EAMods

Member
did you try making your room persistient?
in doing so it should make all instances and the room continue to run hense making them"exist" even if in a different room.
 

Nidoking

Member
in doing so it should make all instances and the room continue to run hense making them"exist" even if in a different room.
No steps will happen to instances not in the current room. Room persistence just means that if you return to the room, it will remain in its last state rather than being recreated as it was in the Room Editor.
 

EAMods

Member
i guess then you could brute force it and make different rooms all in the same room if you know what i mean. just use different camera positions and if the player needs to teleport then change the x and y positions. i mean it would be better than not being able to do it in the first place.
 

Nidoking

Member
But then every room in your game is running all of its instances every step, minus the Draw events for the ones outside the view. Trust me, when time is a linear variable, it's a lot easier to track JUST the time and then when you return to a room, figure out how much has changed in that time. I don't know why you're so determined to do things a more complicated way.
 

minitaba

Member
i guess then you could brute force it and make different rooms all in the same room if you know what i mean. just use different camera positions and if the player needs to teleport then change the x and y positions. i mean it would be better than not being able to do it in the first place.
Like I said, i solved it by saving the day its safed and adding a day when its a new day. Running all my rooms and instances all the would be a big issue performance wise, there may be hundred of plants alone plus different stuff in other rooms going on. But thanks amyway
 
Last edited:
Top