Rubyist Introduction
This is a short explanation of some of what you can do with the Daimoku shared Interactive Ruby console. For more information, see the in-game API
Your IO object
Kernel::puts is not available within the game world, so if you want to write code that will output, you will have to use your IO object. When you log into the game, the system will create an IO object for you. You can test your IO object, by entering the following:
IOmynickSESSION.puts 'hello world' => 'hello world'
Your LEGO object
The LEGO object, allows you to access special builder objects to manipulate the game-world database. When accessing lower-level objects, you will use your LEGO object as an interface.
LEGO api to be determined
Shared Interactive Ruby Interpreter (all objects are immediately shareable)
Let’s say we create the following, in the game
>> a = "Apple" => "Apple"
Now that you’ve created a String and it’s referenced by the variable ‘a’, that variable is immediately available to any other Players within the game world.
Import and run Ruby code into the Game World, from the Internet, in real time
Let’s you have some Ruby code located at http://yoursite.com/yourcode.txt that contained the following:
a = "Super Duper" b = " Trooper" c = a + b puts c
Enter the following, in the game
>> myhardline = HardLine.new(IOyournick1TPQ5L55) => " #<HardLine:0xb74ff508 @interface= IOyournick1TPQ5L55 > >> myhardline.request 'http://yoursite.com/yourcode.txt' => nil >>myhardline.eval Super Duper Trooper => nil
As you can see the code was imported and evaluated, and the variables instantiated within the game world. The objects, a and b and c, are now available to anyone within the game world.
Modify the Room or build new Rooms
The following, show how we create a PlaceBuilder and tell it to build a room that is ‘down’ from the current room, then we go down into that newly created room.
>> pb = PlaceBuilder.new IOyournick1TPQ5L55 => #<PlaceBuilder:0xb751a72c @interface= IOyournick1TPQ5L55 > >> pb.build_down "China", "Many people live in China" => "Done." >> exits Ways out: north south east west up down >> down Going down... China Many people live in China You are alone. >>
Run a socket servers within the game world, to connect to the Internet
The SocketServer class is the high level class that allows the Player to create a line-oriented TCP server. The SocketServer will only listen on ports 2010 to 2260
ssh = SocketServerHandler.new IOjoe3845T23N ss = SocketServer.new(ssh, 2010, 0) ss.start ss.stop
You will need to override the SocketServerHandler::on_input to handle the input and send data out to the client on the Internet
Run socket clients within the game world, to connect to the Internet
Use your IO object so that you can see the data stream:
a = SocketClientHandler.new IOjoe234F84W b = SocketClient.new(a, ‘127.0.0.1’, 2010)
You will need to override the SocketClientHandler::on_input to handle the input and send data out to the server on the Internet