[Resolved][XP] Save Event Position

Started by ShadowSaber, April 09, 2011, 09:20:29 am

Previous topic - Next topic

ShadowSaber

April 09, 2011, 09:20:29 am Last Edit: April 12, 2011, 01:13:41 am by ShadowSaber
Hello everyone, I want to request script that save every event position in the map
so when character leave the map and came back again, the event position didn't reset

thanks in advance

Blizzard

That is not really doable. It would result in savefiles that are several MB in sizes, maybe even dozens of MB. This would also increase saving and loading times dramatically. If you really need this kind of thing, decide in which maps you need that and simply use a couple of variables with a parallel process event (that you delete right after setting all the positions that you saved the last time) and another parallel process event that keeps saving the positions.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ShadowSaber

April 09, 2011, 10:36:13 am #2 Last Edit: April 09, 2011, 10:41:09 am by ShadowSaber
ah, forgot to add

the saved position only saved in $game_temp, so if you close rmxp the saved position will lost
that way, the savefiles will stay the same


if I use variable for each event, that will waste a lot of variable, it seems much more efficient for a script

G_G

Quote from: Blizzard on April 09, 2011, 09:39:16 am
That is not really doable. It would result in savefiles that are several MB in sizes, maybe even dozens of MB. This would also increase saving and loading times dramatically. If you really need this kind of thing, decide in which maps you need that and simply use a couple of variables with a parallel process event (that you delete right after setting all the positions that you saved the last time) and another parallel process event that keeps saving the positions.


Maybe not necessarily. We could just use save_data and keep dumping data back into the map file. But of course there could be a risk of file corruption and stuff.

Blizzard

It would still take time. Opening several files takes a lot more time than just one.

Anyway, if it's just temporary, then it's not much of a problem. You would just need a simple Map manager that which you use to create maps. You just "ask" the manager for a map and the manager gives it to you. If the map doesn't exist yet, the manager will load it. If it already exists (basically if you entered a map, left it and entered it again), then it will use that map. This is a script of 20-30 lines of code, very simple to make. It will use somewhat more RAM, though. In this case it would be good to be able to configure the map IDs which should be kept in the memory so not all maps are kept there (since often you have maps that never change like most dungeon maps or maps where you already use switches and variables for the map state).
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ForeverZer0

You are likely gonna have some bugs if you aren't careful. You need to save more than just the coordinates. Any move routes are going to be screwed up because although the event may be starting a different place, they will still start executing their move route from the beginning. I really can't think of any simple way to store data for where in their move routes they should begin, but it shouldn't prove a problem for stationary events.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

That's why I suggested a whole map manager to keep the state of the whole map.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

WinterVisage

This is actually simply doable by an x/y variable per event (as long as you don't have more events than you do available variables).

All you'd need to do is set it so that when you leave your town, lets call it Nooblocity, and go to the level, lets call it Pwnsage Fields, in that teleport event you take every last one of the events x/y positions. When you step onto the teleport event to go back to the town, it'll then replace their "starting" x/y with this new x/y, thus making them remember their last location. The beauty of it is it's simple, the bad part is if you have a few hundred events on one map (hah, I highly doubt you will, but just saying!), you'll have to have two times that value in variables to handle all of them. My suggestion would be name the variables something like this syntax:

0001:{EVENT_NAME1}_X
0002:{EVENT_NAME1}_Y
0003:{EVENT_NAME2}_X
0004:{EVENT_NAME2}_Y

with {EVENT_NAME#} being the name of said event (best you actually name them, as well. That makes dumping the X/Y easier). This'll also be a permanent solution, saving those positions for not only the length of the game, but as well when you save/exit the game. You can even set up an extra common event doing the same thing which'll move the events back to where they were after they moved when you reload (last I remember, when you load in a map and they've moved, they reset back). Obviously, scripts are a little more quick than common events, but in some situations the common event is the easy route.




Click on my eggs and I can make all of your wildest dreams come true >.>

G_G

Wait...self variables + event positions + modifying event creation method = solution?

My genius is showing.

ForeverZer0

This doesn't solve the bug with move routes that will occur. You need to be able to save the index in the event's list, and set it to this on load.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

Quote from: Blizzard on April 09, 2011, 01:40:47 pm
That's why I suggested a whole map manager to keep the state of the whole map.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Quote from: Blizzard on April 10, 2011, 04:13:27 am
Quote from: Blizzard on April 09, 2011, 01:40:47 pm
That's why I suggested a whole map manager to keep the state of the whole map.



Yea yea Blizz, we all know you have a huge ego. :V

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Well of course. Its the internet. We have to read it. Anyways I've read it, I have no idea on how to go about it so meh.

Blizzard

It's this easy.

module MapManager
 
  @maps = {}
  def self.get_map(map_id)
    @maps[map_id] = Game_Map.new if !@maps.has_key?(map_id)
    return @maps[map_id]
  end
 
end

class Game_Map
 
  alias setup_mapmanager_alias setup
  def setup(map_id)
    $game_map = MapManager.get_map(map_id)
    $game_map.setup_mapmanager_alias(map_id)
  end
 
end

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

The Niche

*Freaks out about Blizzard making a script so he *has* to be coming out of retirement*

Note: This is mostly hear to stop someone else saying it and meaning it.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Blizzard

Yeah, I'm not coming out of retirement. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

What if we paid you 20 grand a year to code us scripts?

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Alright then. Career plan change. I shall become a chef, only to live and die alone. Make 50 grand a year. Pay blizzard 20 of it. RMX-OS shall be flawless. And then I will slave drive you to make me minecraft in RMXP.