Scripting Actor Creation

Justinpl

Villager
Member
Joined
Nov 12, 2018
Messages
6
Reaction score
0
First Language
English
Primarily Uses
RMMV
I've been trying to figure out how to create a new actor with custom attributes. Unfortunately I just can't get it quite right.

If someone knows or can tell me where to find the exact command and the necessary arguments and format to script a new Actor I would be super happy.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,254
Reaction score
1,254
First Language
Spanish
Primarily Uses
RMVXA
define "custom attributes"
everything is indeed translatable into parameters and formulas, but some require more parameters than others.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,431
Reaction score
7,712
First Language
German
Primarily Uses
RMMV
Additionally, most commands for actor creation are available by eventing and don't need scripting.
So more details are indeed needed.
 

Justinpl

Villager
Member
Joined
Nov 12, 2018
Messages
6
Reaction score
0
First Language
English
Primarily Uses
RMMV
I mean custom values for the existing properties for the Actor class. Which should be:

battlerName
characterIndex
characterName
classId
equips
faceIndex
faceName
id
initialLevel
maxLevel
meta
name
nickname
note
profile
traits

For now, a code sample that creates a new actor with static values would be great. I don't need anything fancy. I'm pretty sure what I need to do is add an Actor class to the $dataActors array. I just keep getting errors.

From my understanding, the built-in events only allow you to add or change an existing Actors. Not create new ones, especially while the game is running.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,254
Reaction score
1,254
First Language
Spanish
Primarily Uses
RMVXA
You seem to be mixing the concepts.
*Programming languages* define *data structures* that store *data* in memory.
These *data structures* can be further assembled into *objects*, and each *object* open specific *data structures* to the *environment* that we call *properties*, and *properties* can have small processing routines embedded in them that return *values*, which are called *methods*.

Actor *classes* are blueprints that are used to create Actor *objects* based on the *properties* and *methods* they include.
if you want to modify the Actor *class*, you add a *property* or *method* to it.
Or, you can just rewrite it completely and add the properties and methods you want.... the problem is, the rest of the program will still be looking for the original ones and most likely crash.

Adding, you can add whatever you want to a class directly, even in run time, as long as it doesn't affect what's already declared for it that is already running.
If you want to add something without modifying the existing structure, you can *alias* methods, which is basically redirecting the program to run your code and then go back to the intended point before the modification without breaking the original flow.


If you mean to create a new *ACTOR* (character), you can, even directly, and even in run time.
........you just run the corresponding code manually as the interpreter runs it.... just like that.
I believe the simplest skeleton to create a new actor is basically something like:
Code:
chr = Actor.new()
chr.property = valueX
chr.property2 = valueY
chr.property3 = valueZ
....
chr.propertyN = valueN

$object[index] = chr
where $object is the database and index is a non-used slot in the database.
you invoke the copy of the Actor class skeleton by Actor.new(), then set up the basic properties, and then copy the finished object over to the database and save it.
(very basic language-generic explanation)
 
Last edited:

Justinpl

Villager
Member
Joined
Nov 12, 2018
Messages
6
Reaction score
0
First Language
English
Primarily Uses
RMMV
I think just acting trying to explain what I needed to do helped me out. The code below generated a new actor and added it to my party. Next I'm going to create ways to calculate or determine the values.

child = {
"id":9,
"traits":[],
"initialLevel":1,
"maxLevel":99,
"profile":"",
"battlerName":"",
"characterIndex":1
,"characterName":"",
"faceIndex":1,
"faceName":"",
"name":"Name",
"nickname":"",
"note":"",
"classId":1,
"equips": []​
};

$dataActors.push(child);

$gameParty.addActor(9);
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,254
Reaction score
1,254
First Language
Spanish
Primarily Uses
RMVXA
"child" is just a hash.
you need *an actor-class object*
"pushing" the hash 'child' into the library $dataActors will throw an error, because they're different objects.
you could potentially just map the contents of "child" to their equivalent of "actor"... there are methods for that.

$gameParty.addActor(9) will just copy actor 9 from the database to the party.
if it doesn't exist, it'll do nothing (or, it'll throw an error)
 

Justinpl

Villager
Member
Joined
Nov 12, 2018
Messages
6
Reaction score
0
First Language
English
Primarily Uses
RMMV
Maybe I’ll run into other errors down the road but it ran exactly as intended. It created an actor in the unused actorid 9 with the specified values and then added it to my party once I activated. Since then I changed the 9 in child and $gameParty.addActor() to $dataActors.length and $dataActors.length-1 respectively so it isn’t hard coded. I get a new party member each time I activate the event.

My understanding is that $dataActors is an array of hashes. Each hash represents a different Actor.

I did stop once a new member was added to the party without creating an error. I’ll play around with them and see if any other issues pop up.
 

ougitou1

Invisible Black
Veteran
Joined
Dec 9, 2015
Messages
109
Reaction score
10
First Language
en-
Primarily Uses
N/A
ha ha i would love to help you but i wont, it probably has to do with the fact that i cant... sorry.
 

Justinpl

Villager
Member
Joined
Nov 12, 2018
Messages
6
Reaction score
0
First Language
English
Primarily Uses
RMMV
No worries, I figured this particular issue out. I'm bashing my head over other issues currently haha
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
My understanding is that $dataActors is an array of hashes. Each hash represents a different Actor.
Exactly. In Javascript it's not called a hash but you get the point.

Look no further than the actual source of the information, the Actors.json file to see an example:
Code:
{"id":1,"battlerName":"Actor1_1","characterIndex":0,"characterName":"Actor1","classId":1,"equips":[1,1,2,3,0],"faceIndex":0,"faceName":"Actor1","traits":[],"initialLevel":1,"maxLevel":99,"name":"Harold","nickname":"","note":"","profile":""},
 

Justinpl

Villager
Member
Joined
Nov 12, 2018
Messages
6
Reaction score
0
First Language
English
Primarily Uses
RMMV
I’m on like day three of JavaScript so I’m still figuring terms out.

I had looked in rpg_objects.js and found similar code. I hadn’t thought to look in the Json though. That would probably make things easier.

I was originally expecting to find a constructor method for the Actor class that I could pass those values. The one I found only seemed to take an actor Id. When I tried that I just got an error saying something about an isAppeared of null. Just adding the dictionary to the array seemed like cheating but it got the job done.

https://kinoar.github.io/rmmv-doc-web/classes/game_actor.html#constructor

This site proved very helpful but I just wish there were some examples.

I figured out how to bring up the console and I’ve been running code ,trial and error, using the interactive interpreter. That’s been a huge help too.
 

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

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.

Forum statistics

Threads
106,038
Messages
1,018,466
Members
137,821
Latest member
Capterson
Top