require "Command.rb" require "Commands.rb" require "Room.rb" module RubyMud class Create < Command def words return ["c","create"] end def initialize() super() end def canUse?(object) return true if object.getFlagByClass(Admin) != nil or object.getFlagByClass(Builder) != nil return false end def execute(clientConnection,string) tokens = string.split(' ') # Check the parameters if (tokens.length < 3) clientConnection.send("create classname name\r\n") return true end # Get the current room currentRoom = clientConnection.player.parent classname = tokens[1] tokens.delete_at(0) tokens.delete_at(0) rest = tokens.join(" ") # Create the object begin eval("#{classname}.new(currentRoom,\"#{rest}\")") rescue Exception => detail clientConnection.send("---------------------\r\n") clientConnection.send($!.to_s().gsub(/[\n]/, "\r\n")+"\r\n") clientConnection.send(detail.backtrace.join("\r\n")) clientConnection.send("\r\n") clientConnection.send("---------------------\r\n") clientConnection.send("\r\n") clientConnection.send("<red>Could not create a #{classname}\r\n") return true end # send to client clientConnection.send("#{classname} created\r\n") clientConnection.send("remember to set a decription and attach relevant flags\r\n") return true end end # Create the instance, it adds itself to the commands list Create.new() end # module