Lemur

Crazed Ruby Hacker
Veteran
Joined
Dec 1, 2014
Messages
106
Reaction score
124
First Language
English
Primarily Uses
Fair warning ahead of time on this post, this is going to range far more into production Javascript practices I've used at work.


So then, to start off with, what is the general stance towards testing? To cover mine:


What is testing?


Whenever I'm writing any code I want to be sure works a certain way, I tend to write a test to ensure it.


Say I have a simple adder function:


function adder (x, y) { return x + y; }


A test for it in something like Jasmine would look like this:


describe('adder', function () {
it('adds two numbers', function () {
expect(adder(2,3)).toEqual(5);
});
});


Why bother, my code works!


Well, yeah, for now. How often though is it that you change one little thing and everything else breaks? Testing is a way to ensure that you don't introduce regressions into your code.


Testing, for me, becomes more of a safety net against silly little mistakes that end up taking hours to hunt down with some console logging of some sort.


How would I use that in RPG Maker?


That's a good question, and one I really don't have an answer to quite yet. What I would think of as a good solution is to introduce a spec folder into your project which contains any test code. Combine that with a few tools from NodeJS and NPM and you could be transpiling ES6 or the like instead of writing straight Javascript (ES5)


The nice thing about this version is that the folder is wide open as well as the code in it. That means a sufficiently clever person can rig up NPM to work as a package manager as well instead of having to copy-paste scripts you want.


Transpiling?


So Javascript on its own is kinda hard to look at and has its fair share of warts that make it a pain. Transpiling is the process of transforming a different language into javascript.


A few of them I tend to be a fan of:


Ecmascript 6 - http://blog.teamtreehouse.com/get-started-ecmascript-6


// Default arguments
function sayHi (name = "Brandon") {
return "Hi there " + name;
}

// How about classes?
class Person {
constructor(name = "Brandon", age = 25) {
this.name = name;
this.age = age;
}

isAdult () {
this.age > 18;
}
}

// Not a fan of current function syntax or scoping woes? Arrow functions:
var adder = (x, y) => { x + y; }
// Which is really handy for higher order functions:
[1,2,3,4,5].map((x) => x * 2);




Coffeescript - http://coffeescript.org/


A favorite of Ruby land, a lot more examples are available on that site.


// Arrow functions look like Ruby lambdas instead:
square = (x) -> x * x

// Objects look a lot more like YML
kids =
brother:
name: "Max"
age: 11
sister:
name: "Ida"
age: 9

// Conditionals are nicer
mood = greatlyImproved if singing

if happy and knowsIt
clapsHands()
chaChaCha()
else
showIt()

date = if friday then sue else jill




Livescript - http://livescript.net/


I like Haskell, F#, Scala, Elixir, and ML type languages. Livescript gives me a lot of that:


// Pipes are fun
list = [1,2,3,4,5] |> reverse |> head

// Functional composition
odd = (not) << even

// Inline functions
3 `adder` 4




NPM?


Node Package Manager. Combine with other managers like bower and you could have a versioned library of plugins at your disposal. Well, assuming plugin authors respect semantic versioning and don't break things.


If someone made a Yeoman generator for creating plugins, you could even make a community template for them that'd set up everything from specs to layout.


Of course this is just me rambling


Feel free to carry on, just blowing off a list of ideas I had while I was poking around.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,861
First Language
English
A packaging/versioning system would be useful, especially if it can indicate users that there are new versions for plugins. I don't know if there's already one that people are using for MV plugins.


The biggest problem, to me, is the installation process: if someone were to install a new plugin (or set of plugins), they would have to re-open their project in order to load the changes.


This is OK, but if they forget to do it, then all the changes are overwritten.


On the other hand, I guess they could just install the package again, and the plugins will be added if they don't already exist, so that's not too big of an issue.


For testing, I would be interested in some sort of testing framework, though it would be massive undertaking to provide test suites for the entire base project, and something I'm not too interested in taking charge of.
 

Lemur

Crazed Ruby Hacker
Veteran
Joined
Dec 1, 2014
Messages
106
Reaction score
124
First Language
English
Primarily Uses
The only way I can reasonably test the current code is if I port it to RequireJS modules or do some really hacky inclusions with eval.
 

aitorllj93

Warper
Member
Joined
Jan 3, 2016
Messages
3
Reaction score
2
First Language
Spanish
Hi!


I always wanted to give a try to RPG Maker but I haven't dedicated the time I would like (I work at web developmet and when I arrive home I only want to play games and watch tv series XD)


With the RPG Maker MV release and the change to JavaScript language (which is the language I use at work) I'm really interested in those potential integrations with npm, cordova and other great tools I already know (TypeScript fits nice too)


If I get some time I can help looking about how we could make this work.


Another interesting thing would be a tool for managing paid content (steam dlcs and rpg maker web products) and installing in our projects
 

kentaromiura

Veteran
Veteran
Joined
Nov 1, 2015
Messages
46
Reaction score
26
First Language
English
Primarily Uses
So I saw this thread since it has been bumped, since my https://github.com/kentaromiura/RPGMV-Plugins already did part of what the OP asked, I though it could be useful to extend it into https://github.com/kentaromiura/RPGMV-BASE


I added ES2015 support (through babel), and configured it to run tests through jest when you run `npm test`.
I added a couple of example tests, and I left an example of plugin that I changed to use ES2015 (nothing major, just added some arrow functions).


I also made an example using import and export instead of common js.
 

Latest Threads

Latest Posts

Latest Profile Posts

Today is the day! I will be productive in game dev work! I will - *gets distracted by cat playing with her toy mouse* Awww <3
Whelp. I tried to be productive.
Decided to work on Fandom Scouts today. I've decided that instead of using the generic "scrolling text" event that MV has (I'm using MV for FS, not MZ) I'll use the movie option. I'm still trying to find a way to get Premiere Pro to output the compatible format though. If anyone can give me some help, it would be greatly appreciated!
Barthdry wrote on tln143's profile.
Hello tln143 Welcome to the RPG Maker Forum. We wish you enjoy and make good rpg games
Barthdry wrote on 00cassiesmells's profile.
Hello 00casiemells Welcome to the RPG Maker Forum. We wish you enjoy and make good rpg games
Remember guys: Drink water and workout is important too! Don't stay too much time on the PC working! :D

Forum statistics

Threads
109,034
Messages
1,041,502
Members
141,521
Latest member
Lionheartboi
Top