Conversion some codes RGSS3 to Javascript

LucasRiot

HUMANELFO
Veteran
Joined
Apr 13, 2013
Messages
56
Reaction score
18
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,091
Reaction score
1,508
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
56
Reaction score
18
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:


Maps:



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



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



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.


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


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
31,367
Reaction score
7,676
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,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
[move]JS Plugin Requests[/move]
 

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

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
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.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top