Currently you are able to create Ruby scripts which provide some basic functionality for the server. Many of the reasons that some things are not hugely functional is because the feature has not been totally implemented with the server. The only part which is fully usable via Ruby scripts are "message handlers", which allows you to redefine and extend the server's protocol.
Here is a small example:
Code: Select all
class EquipHandler < Tmw::MessageHandler def initialize() super end def receiveMessage(computer, message) print "Message ID: ", message.getId(), "\n" item = message.readLong() slot = message.readByte() print "Trying to equip ", item, " at ", slot.to_i(), "\n" result = Tmw::MessageOut.new() result.writeShort(Tmw::SMSG_EQUIP_RESPONSE) result.writeByte(Tmw::EQUIP_OK) computer.send(result.getPacket()) end end Tmw::connectionHandler.registerHandler(Tmw::CMSG_EQUIP, EquipHandler.new())
Now i will be working on making everything work nicely and interact in the game world, and providing support for scripted enemies & items.