Jump to content
Sign in to follow this  


Recommended Posts

What is a REPL?


REPL stands for read-evaluate-print-loop it's a simple way to interact with a programming environment. You type in lines of code in a shell or GUI (read), the code is evaluated dynamically (evaluate), and then return value of the code is printed on the screen (print) and then this process loops until the user quits (loop).


What is an Alex?


Everyone knows Alex the greatest hero ever! It's also the name of this script because I needed a name and this was the first thing that popped in to my head. :P

Alex is sort of an improved version of the Interactive Console script/system I made (there's a tutorial in the tutorial forum). For some reason I figured that you couldn't get user input from the RGSS Console (you can!) and when I found that out I started working on this script.


How does it work?


Take look at this demo video I made that shows things you can do with Alex:




  • Plug-n-play
  • Indentation support
  • Start from any point in script editor
  • Start from an event script command
  • Start anywhere by pressing a button
  • Create methods as shortcuts for common strings you use a lot
  • Clear the console window with a command (cls)
  • Can define methods or even classes and module from within an Alex session



First you should now what a binding in Ruby is. A binding is a context that you can get from some point in your program and it encapsulates the value of self, all instance variabels and methods at that point. These can later be accessed through the binding object. You can read more about binding in Ruby here: http://ruby-doc.org/....3/Binding.html


To start an Alex session call the alex method on a binidng. You can get the current Binding instance by calling Kernel#binding. Example:



This will get the current binding and start an alex session. Now all the code you type in will be evaluated in the context of the binding, so you can access all instance variables, methods etc that are available to the binding.


You can put that line anywhere in the editor or in an event script call. It will start an Alex session at the point in the program where the line is executed and you will be able to access everything you normally would be able to access at that point in the Alex session.


When you start a session the game will pause (don't worry if it becomes unresponsive, this is normal) and you can type in code in the Console that will then be evaluated, and the return value is printed.


To stop an Alex session and return to the game, type in exit. You can then switch back to the game window and the game will continue.


To clear the Console screen type in cls.


When you are in an Alex session it is useful to be able to call instance_eval on object (instance_eval allows you to execute code form outside an object as if you were inside the object). Therefore Alex provides shortcut to instance eval called 'ie'. Example:

1.ie("self") => 1


Another thing you can do in Alex is define common methods for things you want to use frequently in Alex session so you don't have to type them in every time. You can put those method in the Common module. Have a look there to see some examples.


You can also start an Alex session anywhere when playing the game game by pressing a predefined key. This will start a session with the current binding as the context. The default key is D but this can be changed in the CONFIG module.





Edited by Kal

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

Top ArrowTop Arrow Highlighted