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
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.
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
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.
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).
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.
That's why I suggested a whole map manager to keep the state of the whole map.
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.
Wait...self variables + event positions + modifying event creation method = solution?
My genius is showing.
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.
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.
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
Nobody listens to my advice. ._.
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.
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
*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.
Yeah, I'm not coming out of retirement. xD
What if we paid you 20 grand a year to code us scripts?
Then yes.
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.
And I shall labour night and day to render G_G immortal.
so, is anyone willing to do this?
Lol, I already did.
Quote from: Blizzard on April 10, 2011, 02:11:40 pm
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
oh thanks :D, but, can you tell me how to use it?
Just insert is above main and that's that. No need to do anything.
Holy crap I thought that was like a base leading us in a direction or something. My god blizzard you beast.
Blizzard came out of retirement, made one script, got bored and went back.
:rofl:
Quote from: Blizzard on April 11, 2011, 04:14:59 am
Just insert is above main and that's that. No need to do anything.
i didn't understand, I placed the script above main and the script have no effect?
I even testing it in new project without any custom script
I made a small mistake, my bad. Try this.
module MapManager
@maps = {}
def self.get_map(map_id)
if !@maps.has_key?(map_id)
@maps[map_id] = Game_Map.new
@maps[map_id].setup_mapmanager_alias(map_id)
end
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)
end
end
I have error with the new script :(
(http://img864.imageshack.us/img864/7751/unledsn.jpg)
here
class EventManager
attr_accessor :events
def initialize
@events = {}
end
end
$eventmanager = EventManager.new
class Game_Map
attr_reader :events
alias setup_eventmanager_alias setup
def setup(map_id)
setup_eventmanager_alias(map_id)
if $eventmanager.events[map_id] != nil
@events = $eventmanager.events[map_id]
refresh
else
$eventmanager.events[map_id] = @events
end
end
end
thank you very much, it works :D