Select Function problem

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
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,281
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

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.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,574
Latest member
nikisknight
Top