Lets make some new objects
There are a couple of ways you can create new objects, iether make a new object and set its properties, or copy an existing object.
Making a new object from scratch
Using the 'new' statement you can quickly make a new object. Here is how we make a new leaf each time our tree object is pushed:
##push:runsub isitme;
##isitme:if $actor eq $target then dropit else end;
##dropit:
new a leaf;
say 'msg',"[$init_obj] shook [$new_id] from [$actor]";
The 'new' statement behaves like the create command in cow, so you could:
new a leaf worth 5;
new some leaves which are slightly moudly;
The useful thing about the new statement is that it cant accept a variable like this:
var $newthing to (a broken bottle,a cardboard box,an old bus);
new $newthing;
The new statement gives you the variable $new_id that refers to the new object. It also replaces the $target with this new object's ID however you can still access it with $old_target if need be.
I prefer grabing a copy of the $target ID before making a new object if I plan to refer to that target object again, just to be on the safe side.
var $last_target to $target;
Make a new object by coping an existing one
This method is used if you have a rather complex object you want you create as it saves you having to set all of the attributes of the new object once it has been created.
By storing base objects within the actor, you can find on of them, copy it then change its location (this is how the fisherman works).
##push:runsub isitme;
##isitme:if $actor eq $target then dropit else end;
##dropit:
find $actor,random;
copy $found_id;
set $new_id's loc to $loc;
say 'msg',"[$init_obj] shook [$new_id] from [$actor]";
This will work if we have at least one object inside our actor. That object can be coded and coloured and describe as required. The fisherman and eskimo use this to randomly fish out an object.
We first find it, then copy it, then move it out to the current location.
Notice that the copy statement gives us a $new_id which we can then manipulate as required.
It also gives us a $new_loc, being the location of the new object, but I have not worked out how this might be useful yet.
By using the $init_obj (initiating object) as the destination for your new object, you plant it directly inside the player who pushed it. This can be handy if you need to give a player something as a reward without others being able to grab it first.