How to create a new event via Script?

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
20
First Language
Italian
Hi everybody,

I'm having trouble trying to create an event via script, at the moment I'm trying through the console but I haven't go any result so far.

I tried doing this:

$gameMap._events[4] = $gameMap._events[3];In the map i'm using for testing events go up only to 3 so with this line i tried to create a new event and copy it from an existing event to fill-out every paramenter in a way that should be functional.

The only thing this made is to speed up the event3, I guessed it had to do with the fact that at the moment of the creation the new event shares the same event Id with the mold, so maybe somewhere in the code his movement is called twice or something like that. At that point i tried to change the event id like this but it resulted in a fatal error:

$gameMap._events[4]._eventId = 4;So I searched for where in the script a new event is created calling the Game_Event constructor ad i found this

Game_Map.prototype.setupEvents = function() {    this._events = [];    for (var i = 0; i < $dataMap.events.length; i++) {        if ($dataMap.events) {            this._events = new Game_Event(this._mapId, i);        }    }    this._commonEvents = this.parallelCommonEvents().map(function(commonEvent) {        return new Game_CommonEvent(commonEvent.id);    });    this.refreshTileEvents();};So I tried this line

$gameMap._events[4] = new Game_Event($gameMap._mapId, 4);but it gave me error until i populated $dataMap.events[4], but still it doesn't seem to work properly.


Any Idea?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Which plugins have you installed for cloning events? Please link to them.


(You'll need a plugin for that as it's not exactly easy to do)
 

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
20
First Language
Italian
None at the moment, i was trying to do that by myself without any result, are there plugins around to do that?

edit: btw what i need is a way to create a new event via script for some uses, cloning one was just a makeshift solution i tried to do
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
edit: btw what i need is a way to create a new event via script for some uses, cloning one was just a makeshift solution i tried to do
I really suggest that you forget the idea to create events by script - that is much more complex, and the experience from Ace (where such a script was written by Tsukihime) shows that you're much better off to create the events in the editor and clone them from a master map than creating them by scripting.
The problem is that events can't be simply copied, they need to be cloned with the clone registered as a new event but keeping 99% of the original data (not 100% - that's why you need to clone it with new IDs instead of copying it)..
 

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
20
First Language
Italian
The idea of copying them from a master map seems not bad, you how could i do that? so far cloning for me has not gone very well lol :p

Let's say for example i have this master map with like 2 or 3of these events, how can I clone them in the running map? i guess I'll have to do something like copying the $gameMap._events[] and the $dataMap.events[] as well and change the ids.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
That is why I suggested to look for a clone event plugin - cloning needs a bit more than just copying data, and if I remember correctly someone already made such a plugin (or is working on one)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I've moved this thread to JS/Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top