How do I force to create an actor in the database?

ArkDG

Veteran
Veteran
Joined
May 26, 2013
Messages
143
Reaction score
48
First Language
portuguese
Primarily Uses
I want to force the creation of an actor in the game database on the start of my plugin, that I can call by an ID defined by the user or me on parameters.

I did the parameters and everything. I can just guide the developper to create the actor himself in the database before the game starts in the number ID he wants. But I want to force the creation of the actor with the script, so I turn it more automatic. And if possible, an actor with a custom ID that is not a number, but a string like "ark_actor_id". If it's not possible to make this string ID thing, just the number is ok for me.

Any ideas?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,425
Reaction score
7,710
First Language
German
Primarily Uses
RMMV
The database is read-only for the engine. So to add an actor during runtime, you'll need a plugin that stored the new actors in the savefile instead of the database files, and redirect the engine to load data from the savefiles for actors with an ID beyond the database.


But saving into the database is a bad idea, even if theoretically that is possible with json files...
 

ArkDG

Veteran
Veteran
Joined
May 26, 2013
Messages
143
Reaction score
48
First Language
portuguese
Primarily Uses
Yeah, I thought that this would be the right way to do this.

So, I saw that the Actors.json is stored inside the $dataActors. And I can get informaitons about an actor with an id using:

console.log($gameActors.actor(id));

After I started the game. $gameActors is an object and it's accessible fro the datamanager. 

How can I just add inside it the actor I want?

Would I really need to change all the way the engine check for the actors in the game, or can just adding information to this variable solve the problem?

EDITED
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Not really a great idea. $dataActors is from the database and is shared between games. $gameActors is for the one game only, but not everything on the actor is stored in $gameActors - some things still go back to the $dataActors array. So by changing it, you're affecting other games as well.


Can you explain why you want to do this? It may be that there's a better/easier way of accomplishing your goal.
 

ArkDG

Veteran
Veteran
Joined
May 26, 2013
Messages
143
Reaction score
48
First Language
portuguese
Primarily Uses
Well... I need a text input system to register diferent names and register them in variables. I could create a input justo for this (and this plugin exists, darkkitten did it) or just use the rmmv default input by colecting the information from the actor name.

By now the user would need to create this actor and register its id on the plugin for my idea to work. But if I could create this false or additional actor, with a unique id, everything would be much more easy.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Can't you just use a 'dummy' actor that's already set up in the database but is never used in the party?
 

ArkDG

Veteran
Veteran
Joined
May 26, 2013
Messages
143
Reaction score
48
First Language
portuguese
Primarily Uses
Yeah, as I said I could ask the user to create this dummy actor and register its ID.Actually this is what I'm doing.

But if I'm capable of evading this step by creating with the plugin code myself this dummy actor, tgat would be more elegant and confortable for the game developper. And this knowlodge could even be good for future needs.

One mor ething. I don't want to create actor everytime with the plugin. Just on the first start of a play test. The developper will test the game and automatically tthis actor will be added to his game. One time this is made, I will have the dummy actor I need.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,425
Reaction score
7,710
First Language
German
Primarily Uses
RMMV
Yeah, as I said I could ask the user to create this dummy actor and register its ID.Actually this is what I'm doing.
wrong, that is not what Shaz was talking about.
Shaz was asking you why you as the developer don't create the dummy actor in the database in the editor and use that for text input, without ever using scripts or plugins for that.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
I think the OP is making a plugin, and the plugin relies on there being a dummy actor in the database, so he/she wants to create the dummy actor so the game developer doesn't have to.


All you have to do is create a new object, set up the default settings, give it an id one more than the last $dataActors' id, and then do whatever you want with it. The question is, do you want to actually update $dataActors (which means the developer could then go and delete it again when they go back to work on the game, and/or you would have to keep track of whether it had been done or not so you don't go adding new actors to $dataActors every time they run the game), or do you want to create a $gameActors object based on it, and as I said above, it still requires a $dataActors object for those things that don't specifically get placed in the $gameActors object.


tbh I don't think people using your plugin would have an issue with setting up a dummy actor. If your plugin allows them to enter a parameter for actor id, it's that easy. Much like plugins that require the user to specify what switches or variables they want to use - those plugins don't check what's already in use and allocate new ones.
 

ArkDG

Veteran
Veteran
Joined
May 26, 2013
Messages
143
Reaction score
48
First Language
portuguese
Primarily Uses
Shaz, you understood me. This is exactly what I want.

All you have to do is create a new object, set up the default settings, give it an id one more than the last $dataActors' id, and then do whatever you want with it. The question is, do you want to actually update $dataActors (which means the developer could then go and delete it again when they go back to work on the game, and/or you would have to keep track of whether it had been done or not so you don't go adding new actors to $dataActors every time they run the game), or do you want to create a $gameActors object based on it, and as I said above, it still requires a $dataActors object for those things that don't specifically get placed in the $gameActors object.
Well, let's think about it like a clonning actor feature, but for special purposes. This actor will exists only in the game, and not in the database, but I will be able do call him with the methods I would use for a normal actor.


Anyway, I found a solution without needing to create this actor. I overwrited some Scene_Name funcations to be like that:

Scene_Name.prototype.create = function() { Scene_MenuBase.prototype.create.call(this); if ($gameActors.actor(this._actorId) != null && $gameActors.actor(this._actorId) != undefined) { this._actor = $gameActors.actor(this._actorId); } else { this._actor = $gameActors.actor(); } this.createEditWindow(); this.createInputWindow();};Window_NameEdit.prototype.initialize = function(actor, maxLength) { var width = this.windowWidth(); var height = this.windowHeight(); var x = (Graphics.boxWidth - width) / 2; var y = (Graphics.boxHeight - (height + this.fittingHeight(9) + 8)) / 2; Window_Base.prototype.initialize.call(this, x, y, width, height); this._actor = actor; if($gameActors.actor(this._actorId) != null && $gameActors.actor(this._actorId) != undefined) { this._name = actor.name().slice(0, this._maxLength); } else { this._name = '';} this._index = this._name.length; this._maxLength = maxLength; this._defaultName = this._name; this.deactivate(); this.refresh(); if($gameActors.actor(this._actorId) != null && $gameActors.actor(this._actorId) != undefined) { ImageManager.loadFace(actor.faceName()); }};Window_NameEdit.prototype.refresh = function() { this.contents.clear(); if($gameActors.actor(this._actorId) != null && $gameActors.actor(this._actorId) != undefined) { this.drawActorFace(this._actor, 0, 0); } for (var i = 0; i < this._maxLength; i++) { this.drawUnderline(i); } for (var j = 0; j < this._name.length; j++) { this.drawChar(j); } var rect = this.itemRect(this._index); this.setCursorRect(rect.x, rect.y, rect.width, rect.height);};Scene_Name.prototype.onInputOk = function() { if ($gameActors.actor(this._actorId) != null && $gameActors.actor(this._actorId) != undefined) { this._actor.setName(this._editWindow.name()); } else { $gameVariables.setValue(3, this._editWindow.name());} this.popScene();}; This way the name input will work even for the normal needs as for my needs.

But I still want to know how to make this actor thing. Tell me how you would program this object creation thing. This can be of help for me in the future!
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
You can't make a $gameActors object without a corresponding $dataActors object. As I said, certain functions in Game_Actor look up information from $dataActors, as it's not all encapsulated in $gameActors.


Somebody made a dynamic database plugin, where all of $dataActors (and the other database tabs) get saved to your save file. It might be worth looking at that, as it would allow you to modify $dataActors and have the information saved. But you'd need to check that loading a saved game or starting a new game would force a reload of the saved or original $dataActors, so whatever changes have been made in this game do not affect new games.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,017
Messages
1,018,356
Members
137,802
Latest member
rencarbali
Top