linktree Atrinik.org - Multiplayer Online Role Playing Game  >  Atrinik News  >  Developers' Corner
linktree Topic: Developers Console
Pages: [1]   Go Down
  Print  
Author Topic: Developers Console  (Read 2387 times)
0 Members and 1 Guest are viewing this topic. Bookmarked by 0 members.
Offline Cleo
Developer
Alex Tokar

Posts: 580
Gender: Male
« on: October 10, 2011, 01:23:17 am »

The server has a new command which replaces all of the awkward-to-use commands such as /create, /remove, /patch, /insert_into, etc - in essence, all of the DM commands that deal with object manipulation.

The command is "/console" and it is purely managed by Python and multi-threading, all in under 200 lines of code (with the previous object manipulation code commands being well over 2k lines, if not 3k). One can bring up the console session with a simple "/console" command, and start using the Python scripting interface right away, with the full power of Python, Python modules, Atrinik Python module, etc at one's fingertips:



All of the scripting possibilities are available when using the interface, and the "activator" object (the player that activated the /console command) is available in local namespace. Thus, in order to create an object for example, one can just type activator.CreateObject("beer") in the interface to get a beer arch in their inventory.

The power of the interface comes in with raids and events - it is much more flexible and powerful for this than the old "/create", since one can just create functions prior to the raid that can spawn various different monsters, control them, make them say things, etc. It is also possible to take "ownership" of a mob and control them - make them move around with obj.Move(direction), make them speak with obj.Say(text), etc. All of the possibilities are detailed in the Atrinik Python Plugin Documentation Page, and the Python docs can be found here.

Client implements a "/console-load" command, which allows you to load up your script files directly into your console session - for example, "/console-load geyser.py" would load the code in ~/.atrinik/console/geyser.py into your console session (if it's not started yet, it will be started).

It is possible to macro various things and not have the console session come up, by using for example "/console noinf::fire_geyser()" or "/console noinf::activator.hp = activator.maxhp". Changing an object's message is much easier than it used to be, thanks to Python's string manipulation abilities.

Of course, just with like the previous object manipulation commands, it is still possible to cause a crash or worse with the console, so, with great power comes great responsibility (and on public servers, testing on local beforehand). One thing to probably avoid is threading -- I'm not quite sure how well it works in an interactive Python shell session (which is what the console is, effectively), so it could cause a deadlock if used without care.

The console is fully threaded, so running commands in it will not cause the server to lag/freeze, even if you try to run a loop with a few trillions counter (though it may take a while to complete). Each player's /console session is a unique thread, so several DM's using the command will not interfere with each other.

In other news, the text input history buffer has been rewritten to be more flexible (allowing any number of history lines, as set in the client options [default 40, used to be limited to 20 max due to static buffer]), and more generic - so it can be used for different inputs, not just the main player console, but also the interface, with its own history, separate from the text input console. A new minor but useful feature is that you can now use the down arrow key to erase your text input, but add it to the history buffer - very useful if you're writing a long line but want to quickly respond to something else, then resume writing (or when talking to multiple people at once, for example). Inspired by irssi behavior. :)


* Atrinik-2011-10-08-23-02-18-753501.png (466.9 KB, 1024x768 - viewed 545 times.)
 Logged
Offline Mamoru
Developer
Edwin Miltenburg

Posts: 625
Gender: Male
« Reply #1 on: October 18, 2011, 03:56:24 pm »

I've been playing around with the Developers Console on my server for the past few days. It really is a very powerful tool. It works great for raids, events, etc.

However, I miss the simple short-cut commands for object manipulation. Would it be a good idea to take the old code for the /create, /remove, /patch, /insert_into, etc commands and change it into Client Script(s)?

M.
 Logged
Offline Cleo
Developer
Alex Tokar

Posts: 580
Gender: Male
« Reply #2 on: October 18, 2011, 04:07:16 pm »

If you want to, feel free. It is as simple as creating a "library" of such commands in Python - porting C to Python is impossible.
 Logged
Pages: [1]   Go Up
  Print  
 
Jump to: