You are looking at many info about includes

Cowscript statement include

Syntax: include {object};

You can include the blocks of code from one object into another object as run-time. These blocks of code are added to the current actings objects code and are available for running as if they had saved inot the acting objects code.

This is a temporary thing, the included code is not saved in the acting object.

This can be used where a common library of code is needed. I can imagine some avid coders will have a library of code blocks and include it as required.

There is no limit as to how many or how often or when included code is included.

Included code can even call code from the acting object or from other included code. Just think of the current executing code as code soup and your just adding some more tasty morsels of code to it.. the more the merrier.

However you can not have 2 blocks of code with the same name, so the last one included replaces the previous one. Last in, best dressed.


Example:
You have an object .. Lets assume its obj_id is 999.. containing a few blocks of code:

##saysomething: call "say something";
##shoutsomething: call "shout something";
##dothink: runsub thinksomething;


You also have an object that includes this code:

if target of push then iwaspushed;

##iwaspushed:
include 999;
runsub saysomething;
runsub dothink;

##thinksomething: call "think Hmmm..";


Now lest trace what happens when you push this object:
1) its runs 'iwaspushed'
2) which includes code from our first obect
3) then runs 'saysomething' from the included code
4) then runs 'dothink' also from the included code
5) which in turn runs 'thinksomething' from the acting object

Just to get the concept of priorities in order lets consider this scenario:



Slightly related concept involving inherited code from materials:

When a material's code is used for an object, the objects code is also included as well. This code is included after the material code so its has priority and will override any blocks from the material with matching names.

An example:
There is a material called living
Which reacts to a 'push' by running the block 'sayoi'
If we code a living object to have its own 'sayoi' block, this will be used as it was included last.

Please note, this does not effect reactions. You can not override a reaction, it will simply be done twice.

Just remember the include code only happens after the reaction has been triggered.