Select Function problem

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,282
Reaction score
106
First Language
Irish
Primarily Uses
N/A
def alive_members if @inv_enemy.any? result = members.select{|member| member.alive? && !member.invisible?} if result.size.zero? invisible_enem super else result end else super end endhow can you interpret this in JavaScript / convert in JavaScript. This is placed under Game_Troop.

Also, how do you address the game troop enemies in Game Troop (JavaScript)?
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,282
Reaction score
106
First Language
Irish
Primarily Uses
N/A
You can use the filter function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter

What do you mean with how to address game troop enemies?
I want to address the game troops just like in RGSS3, like this:

result = members.select{|member| member.alive? && !member.unselectable?}
Code:
members.each{|enemy| @unselectable_enemys << enemy.unselectable?}
notice that when we extract, we can have member and enemy inside members? I want to do that as well in MV.

EDIT:

Could you check what's wrong with my Filter?

Game_Troop.prototype.result;Game_Troop.prototype.invisibleMembers= function() { for (var x = 0; x < this.invisible_enemies.length; x++) { members.forEach(function(enemy, index, members) { if (enemy.isAlive() && enemy.invisible_enemy) { this.result = enemy; } }); if (this.result.size == 0) { this.invisible_enemy(); //super? } else { return this.result; } } // super?I left the //super comment because on the snippet I was trying to convert there was a super method. Is there an equivalent of super in JS?
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

Latest Profile Posts

My first Video Scene - Kraken Art By @whtdragon -

Still needs work but its a start.
Considering a side project of making a Choose Your Own Adventure in MV but letting people play it as YouTube videos with the choices at the end leading to other videos. Thoughts?
I've made a rudimentary prototype map for the first game with the MV RTP overworld tiling. I'm probably going to photoshop the crap out of it for parallax, but the prototype has given me new ideas about how I want to place dungeons in the game.
I got tired of not having an avatar image. Couldn't think of anything cool. So I'm just using my game's antagonist instead... How original. At least both of our names start with C?
Expectation: Design/dev a game for the game jam | Reality: "These codes suck, why did I do it this way? lemme fix this. Also what if I add feature xyz because... well, I can."

Forum statistics

Threads
95,635
Messages
930,605
Members
125,950
Latest member
Tocilux
Top