I am trying to save and load the items, the problem I have is that I can’t seem to find a solution to save the coordinates into a file. I made it so the items are actually multiple animations, but it detects just one.
Image is of object “items”.
This image shows the save game conditions, the first part is fine, it is to save the player position.
The second part starts with repeat for each objects, and there is my problem. Even when I have 2 items on the tile map it saves only one instance of the object items.
This is the Load conditions,
Any help is greatly appreciated.
Now, I just briefly looked over, (I am short on ime) but to me, it looks like the save_items info is overwriting itself (I didn’t notice it being appended anywhere), which would explain why it only works for one, it just rewrites the coordinates over itself? Could this be the issue? Maybe try a sperate saveitems2.txt for the wood, and if that works, then you can confirm the info is being rewritten over itself.
I would agree with snobunni, it looks like some of the stuff is overwriting itself.
That said, I’d also say your save/load method is substantially more complex than needed by using string find expressions. I’d recommend just building out a global structure variable named “GameState” and then using that to store all of your variable info that you use in the game. You can then just save that structure variable and load it when needed without having to do a bunch of specialized seeking, since it’ll already be the game logic used.
You can see an example of this in the advanced save/load tutorial on the main youtube
(Method works for storage events or filesystem events)
Sorry to bother you again,
I tried the first solution, overwriting advice, it didn’t work as intended, and yes it is hard to follow with, there might be more problems than just that, so I kept it away for now, since you said there is a more reliable solution.
I have followed the tutorial and did as it said, created a global variable structure, and added a sub variable named Items as I want to save Carrot and Wood position, I have a bit of struggle now … how to “assign” a variable, so it knows which object to save and load, I mean how to connect this variable “Items” with this two animations, Can you give me an example ?
And do I need to separate it into two items or can I keep it as it is ?
And this are the items I meant ( I don’t know if it is the right way to do it, but I used animations)
So, you can make a structure under items, have one “carrots” and one “wood”
Under those, make a structure for the variables attached (ie X, Y, animation, etc…)
you could have a variable in there that goes up by one called “carrot count” as an example, which increase everytime the character picks up a carrot. I hope that helps a bit…
so it would be something like if char picks up carrt, then change the GlobalVariable allmyvars.items.carrots.carrotcount add 1 assuming the entirety of the variables are held in one main structure titled “allmyvars” if you put them under one main variable like in the tut SilverStreak suggested. Hope that makes sense
I watched the video few times and tried to recreate this post that you have gaved me, with some manipulation of the conditions and rewriting the code,
I made it work, the items I had were displaying and loading up correctly.
I am posting my code below.