|
CHAPTER 1
Extra Objects:
Addendum: The EXTRA_OBJECTS was rewritten completely on Apr 1, 2015 (no
April Fools' Day prank) by me, Kiri. The old code with re-implementing
get/take in the room-coe is not really wise ;-) The player has the code
for taking things and it's behaviour might change (in obj/player). This
is also that this page was re-written (almost) completely.
Imagine you are walking through a meadow full of flowers. Sadly you can't
take them, because they are only virtual and only mentioned in the
description. The extra objects feature solves this problem.
STOP: Kiri says in 2015: What's described below can also be accomplished
via produce - see 'man room/produce' :-) The feature described below uses
this, too :-)
To be able to use it you have to define EXTRA_OBJECTS and EXTD_ROOM before
the include <room2.h> line. You can use the following two functions then:
add_extra_object(file, id) adds an extra object.
add_extra_object(file, id, count) adds an extra object.
remove_extra_object(file) removes an extra object.
File is the path where the object is cloned if a player types 'get <item>'
or 'take <item>' where <item> is one of the id's presented in id. Id is of
the same type as already shown with normal items.
The optional new 3rd argument count is the count, the number, of these
objects can be taken between 2 resets. Default is 1. If you set it to
-1, players can take as much as they like! Endless! Only for items with
no value and no special functions like healing etc. The control if there
are items left, is done in the room!
The <item> is removed via remove_item(item) if the items is "exhausted".
Under "standard circumstances" there is no need to fight with
"notify_item_leave" in the room.
If the player can't carry anymore the "now object" stays in the room and
the extra_object is removed. This stays like this until somebody removes
(takes) the object. After the next reset, the item is fully available
again (if everything is done right by you ;-)
Sorry, remapping of an add_action, e.g. pick to the function get_obj in
the room is no longer possible: "pick apple", "pick apple from tree" etc.
has to be done by other means. Now the "get item" is done by obj/player
and not by the room.
So you could add
add_extra_object("room/examples/flowers", "flowers#some flowers")
to your room. Don't forget to reset your extra objects at every reset.
BUT as said above: have a look at 'man room/produce'! :-) I think it's
the better way!
Changed/modified/modernised by Kiri in 2015 and August 2016.
See also: |
|