cmd_delete.rb

znmud-0.0.1/cmd/zombie/cmd_delete.rb · 857 B

From the archive znmud-minimal-0.0.1.tar.gz

Download the archive   « Back to the archive contents

#
# file::    cmd_delete.rb
# ZN Author:: ZombieJesus
# ZN version:: 0.1
# ZN date:: 11/07/2008
#

module Cmd

  # Loads an object based on it's oid
  def cmd_delete(args)
	case args
	when nil, ""
		sendto("Delete what?")
	when /^#(\d+)/
		obj = get_object($1.to_i)
		if (world.is_admin? id) or (world.is_builder? id and obj.owner == id)
			add_event(id,obj.id,:delete)
		else
			sendto("Builders can only edit objects they have created.")
		end
	else
		found = false
		get_object(location).objects.each do |obj|
			if(args == obj.name)
				found = true
				if (world.is_admin? id) or (world.is_builder? id and obj.owner == id)
					add_event(id,obj.id,:delete)
				else
					sendto("You do not have permission to delete that.")
				end
			end
		end
		sendto("There is no #{args} here.") if not found
	end
  end
  
end

Site Stats

Snippets: 1791
Codebases: 571