How badly have I screwed this up?(VX Ace to MV plugin conversion)

I've only just begun my attempt at converting this to MV format with no javascript knowledge what-so-ever so I'm looking for as much advice as I can get.

Spoiler
//Battle transition Plugin
//Converted from it's VX Ace Version to MV by Deathsia
/*
This is my first ever attempt at a javascript plugin. So please provide advice if you can offer it.
==========================================================================================================
Basic Information
==========================================================================================================
This plugin changes the way rpg maker mv handles battle transitions.

As it stands, this plugin only allows for a swirl effect similar to final fantasy 7's battle transition.
==========================================================================================================
*/

function FrameBuffer

var self.start(frames = 1, viewport_z = 10000)
dispose unless disposed?
this_frame = Graphics.snap_to_bitmap
@buffer = []
@viewport = Viewport.new
@viewport.z = viewport_z

var frames.times do
sprite = Sprite.new(@viewport)
sprite.bitmap = this_frame.clone
sprite.x = Graphics.width / 2
sprite.y = Graphics.height / 2
sprite.ox = Graphics.width / 2
sprite.oy = Graphics.height / 2
@buffer.push(sprite)
end
this_frame.dispose
end

var self.dispose
return if disposed?
@buffer.each {|sprite| sprite.dispose}
@viewport.dispose if @viewport
@buffer = nil
end

var self.disposed?
!@buffer
end

//Deletes the oldest frame bitmaps and shuffles all the bitmaps down
//replacing the first frame with a fresh snap shot
var self.cycle
return if disposed?
@buffer[-1].bitmap.dispose
@buffer.each_index do |i|
next if i == 0
@buffer.bitmap = @buffer[i - 1].bitmap
end
@buffer[0].bitmap = Graphics.snap_to_bitmap
end

//Set's all the frame buffer sprites to use a fresh snapshot
var self.refresh
this_frame = Graphics.snap_to_bitmap
@buffer.each do |sprite|
sprite.bitmap.dispose
sprite.bitmap = this_frame.clone
end
this_frame.dispose
end

var self.[](num)
return nil if disposed?
return @buffer[num]
end

end

function Scene_Map < Scene_Base

//--------------------------------------------------------------------------
// Preprocessing for Battle Screen Transition
//--------------------------------------------------------------------------
Scene_Battle.prototype.create = function() {
Graphics.update
Graphics.freeze

FrameBuffer.start(3)

FrameBuffer[0].z = 0
FrameBuffer[0].zoom_x = 1
FrameBuffer[0].zoom_y = 1
FrameBuffer[0].opacity = 235
FrameBuffer[0].angle = 0
FrameBuffer[0].blend_type = 0

FrameBuffer[1].z = 1
FrameBuffer[1].zoom_x = 1.01
FrameBuffer[1].zoom_y = 1.01
FrameBuffer[1].opacity = 128
FrameBuffer[1].angle = 359
FrameBuffer[1].blend_type = 0

FrameBuffer[2].z = 2
FrameBuffer[2].zoom_x = 0.8
FrameBuffer[2].zoom_y = 0.9
FrameBuffer[2].opacity = 12
FrameBuffer[2].angle = 12
FrameBuffer[2].blend_type = 1

@spriteset.dispose_characters
BattleManager.save_bgm_and_bgs
BattleManager.play_battle_bgm
Sound.play_battle_start
end

//--------------------------------------------------------------------------
// Execute Pre-Battle Transition
//--------------------------------------------------------------------------
Scene_Battle.prototype.start = function() {
Graphics.transition(1)
(0..60).each do |i|
Graphics.brightness = 255
FrameBuffer.refresh
Graphics.frame_reset
Graphics.brightness = 255 - (255 * ((i - 40) / 20.0)) if i > 40
Graphics.update
end
FrameBuffer.dispose
Graphics.freeze
end

end




My basic goal/hope is I've done SOMETHING right in this thing so far...it's a plus if I've done alot right so far but I'm not holding my breath!
you forgot {} and ; ?
Would be a stretch in hoping I only forgot it in one or two parts? 😛


*waits for the inevitable: "You kind of forgot everywhere" reply*
Would be a stretch in hoping I only forgot it in one or two parts? 😛


*waits for the inevitable: "You kind of forgot everywhere" reply*

Yep.


JavaScript uses braces instead of blocks that send with the end keyword, and while you can omit semicolons, it's good practice to included them, since the browser will automatically add them by making guesses about your code.


You might benefit from throwing it in Opal first.
I mean, you're... close (I'm telling my internal experienced programmer to shut up - I've been working in VB.Net for work and forget semicolons and braces all the time)...


Some notes!

  • Declaring a function:

    var MyFunctionName = function() { <real code will go between the braces> };

[*]OR

  • function MyFunctionName() { <real code will go between the braces> };

[*]Line of code should end with semicolons - as stated above, your code gets guessed at, and sometimes guesses go very bad:

  • var someString = "This is a string.";

[*]JavaScript does not have an each, for each or any other collection-friendly loop:

  • var someArray = ["Apple", "Banana", "Orange"]; //an array of strings
  • for (var i = 0, n = someArray.length; i < n; i++) { <real code will go between the braces> };

    Note: for this we set the array length to the variable n because getting array lengths in Javascript is costly. This way we do it once.



Other notes:

  • @ in a variable name will possibly cause issues - I don't know.
  • A LOT of this still looks an awful lot like Ruby. Checking out some basics of JavaScript on Code Academy might help.
  • Keep practicing!
I mean, you're... close (I'm telling my internal experienced programmer to shut up - I've been working in VB.Net for work and forget semicolons and braces all the time)...


Some notes!

  • Declaring a function:

    var MyFunctionName = function() { <real code will go between the braces> };

[*]OR

  • function MyFunctionName() { <real code will go between the braces> };

[*]Line of code should end with semicolons - as stated above, your code gets guessed at, and sometimes guesses go very bad:

  • var someString = "This is a string.";

[*]JavaScript does not have an each, for each or any other collection-friendly loop:

  • var someArray = ["Apple", "Banana", "Orange"]; //an array of strings
  • for (var i = 0, n = someArray.length; i < n; i++) { <real code will go between the braces> };

    Note: for this we set the array length to the variable n because getting array lengths in Javascript is costly. This way we do it once.



Other notes:

  • @ in a variable name will possibly cause issues - I don't know.
  • A LOT of this still looks an awful lot like Ruby. Checking out some basics of JavaScript on Code Academy might help.
  • Keep practicing!



How would I go about aliasing the function that changes how RPG Maker handles battle transitions? This is originally a VX Ace script that had a single purpose: To simulate the FF7 swirl battle transition.
How would I go about aliasing the function that changes how RPG Maker handles battle transitions? This is originally a VX Ace script that had a single purpose: To simulate the FF7 swirl battle transition.



Your guess is as good as mine. I was just giving some generic JavaScript advice.

Original thread: https://forums.rpgmakerweb.com/threads/how-badly-have-i-screwed-this-up-vx-ace-to-mv-plugin-conversion.57327/