Drop.rb

RubyMud/Commands/Drop.rb · 775 B

From the archive rbmud-0.1rc2.tar.gz

Download the archive   « Back to the archive contents

require "Command.rb"
require "Commands.rb"

module RubyMud

class Drop < Command
	
	def words
		return ["drop"]
	end	
	
	def initialize()
		super()
	end
	
	def execute(clientConnection,string)
		tokens = string.split(' ')

		if (tokens.length != 2)
			clientConnection.send(tokens[0]+" objectname\r\n")
			return
		end
		
		# Get the current room
		currentRoom = clientConnection.player.parent
		player = clientConnection.player
		
		# Get the item on the player
		item = player.getObjectByName(tokens[1])
		
		if (item == nil)
			clientConnection.send("<red>Cant find that item on you\r\n")
			return
		end

		player.removeItem(item)
		
		currentRoom.dropItem(player,item)		
		
	end
		
end

# Create the instance, it adds itself to the commands list
Drop.new()

end #module

Site Stats

Snippets: 1791
Codebases: 571