LucasRiot

HUMANELFO
Veteran
Joined
Apr 13, 2013
Messages
58
Reaction score
20
First Language
Portuguese
Primarily Uses
N/A
Hello makers!
I would like to know how to convert the codes below RGSS3 to Javascript:
$game_variables[5] = ($game_party.members()[0] ? $game_party.members()[0].name : "-")
$game_variables[6] = ($game_party.members()[1] ? $game_party.members()[1].name : "-")
$game_variables[7] = ($game_party.members()[2] ? $game_party.members()[2].name : "-")
$game_variables[8] = ($game_party.members()[3] ? $game_party.members()[3].name : "-")

$game_variables[9] = $game_party.members()[1]

Conditions > script
map_skills = [
[1, 1, 12], # 1: Eric
[3, 0, 11], # 2: Nathalie
]

id = $game_variables[9].id
map = map_skills[id-1]

$game_variables[10] = map[0]
$game_variables[11] = map[1]
$game_variables[12] = map[2]

I found some pre-defined codes on this site https://kinoar.github.io/rmmv-doc-web/index.html
But as I've never used Java, I've had doubts.
If anyone can help, I appreciate it! ^^
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,411
Reaction score
1,821
First Language
EN
Primarily Uses
RMMZ
Note you can use the Control Variables > Script option to set variables to non-integer values, too! I'm guessing you have a reason to stick to pure script calls, though, so here goes~ :kaojoy:

1) Each line is the same except for the numbers; first line:
Code:
$gameVariables.setValue(5, $gameParty.members()[0] ? $gameParty.members()[0].name() : '-');

2)
Code:
$gameVariables.setValue(9, $gameParty.members()[1]);

3) Not sure what you mean by "Conditions > script" here, but I think this ought to work:
Code:
var mapSkills = [
  [ 1,  1, 12],    // 1: Eric
  [ 3,  0, 11],    // 2: Nathalie
]

var id = $gameVariables.value(9).actorId();
var actSkills = mapSkills[id - 1];

$gameVariables.setValue(10, actSkills[0]);
$gameVariables.setValue(11, actSkills[1]);
$gameVariables.setValue(12, actSkills[2]);
Do make sure variable #9 has an actor stored in it before running this one, though, or it'll cause an error. :kaoback:
 

LucasRiot

HUMANELFO
Veteran
Joined
Apr 13, 2013
Messages
58
Reaction score
20
First Language
Portuguese
Primarily Uses
N/A
I'll explain what I want to do so you have an idea.
It would be a SkillTree system where you take the player to maps where the characters can unlock habillities / spells. Each character has a different map (all 4 characters), after he finished unlocking the skills, he would return to the map / stage he was in.
I defined some variables:
ds293.png


Maps:
2jewfnq.png



Starting with Common Event I have set some commands as you can check below:
dheu68.png



The action of this process begins on the event on any map.
16m7xjd.png



When you talk to an NPC, a window of choices is shown for the player to select which skill map of the characters he wants.
Since at the moment only Haroldo has playable, only his name appears in the choices, if you have more characters in the team, the names will appear. So far everything is working.
fcij6c.png


The problem occurs when the player selects the character, instead of being teleported to his skill map, the game crashes.
35lhm5t.png


Well, in this case what would be going wrong in processing the common event?
Thanks in advance.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,504
Reaction score
8,144
First Language
German
Primarily Uses
RMMV
The Problem here is that the script event command is sandboxed. All newly defined variables inside a scriptbox are deleted when the scriptbox is closed.
That results in the "$selected_actor" being undefined in later script boxes.

You'll either need to store this in a normal game variable or use a plugin to define them outside a scriptbox.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,305
Reaction score
11,734
First Language
English
Primarily Uses
RMVXA
[move]JS Plugin Requests[/move]
 

Latest Threads

Latest Posts

Latest Profile Posts

Screenshot-2021-05-02-at-15-07-54.png


Tivadar will help you travel to distant places in Eniko: Ghosts Of Grace

Finally done with the school project, here's the raw video of it. o_O :smile:
Can February March? No, but April May.

Forum statistics

Threads
111,175
Messages
1,058,980
Members
144,421
Latest member
luok
Top