#!/usr/bin/perl
#use Mooix::Thing;
#use Mooix::Root;
run sub {
	my $this=shift;
	%_=@_;
	my $avatar=$_{avatar};
	my $oldloc = $this->location;
	
	if ($oldloc == $avatar) {
		fail "You already have that.";
	}
	if ($this->physics->move(object => $this, to => $avatar)) {
		my $room=$avatar->location;
		my @locs;
		my $obj=$this;
		my $oldprep = "from";
		while ($oldloc && $oldloc != $room && $oldloc != $avatar) {
	                push @locs, $oldprep, $oldloc->prettyname;
			$obj=$oldloc;
			$oldprep=($obj->preposition)[0];
			$oldloc=$oldloc->location;
	        }
		if (@locs) {
			$_{fromcontainer}=" ".join(" ", @locs);
		}
		$this->msg('take', %_);
	}
	else {
		fail "You can't take that.";
	}
}
