RPG Maker Forums

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.

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,446
Members
137,820
Latest member
georg09byron
Top