The purpose of the document is to describe how to make a function .inc file.
The idea is to make the each object pluggable as ONE file, where all you have
to do is put a .inc in the function directory and the function will automatically
show up in the javascript phpcad menu and work for movies, povray, and pictures.
Take the function out, and it will not show up.

If you make an error, debugging a function, you will not be able to tell
which line of code the error came from.  Thus, to debug it might be advisable
to cut out the code between the letters and paste it in the appropriate
php script temporarily.  There will be markers in the php code where you can post
the script temporarily for testing.

In each .inc, you will notice a bunch of AAAAAAAA, BBBBBBB, CCCCCCC, DDDDDDD,
and EEEEEEEE.  These dividers are each 15 or more characters long, if you use
less, the php code will not be able to separate the sections and you will get
errors.  The easiest way to make a new function is to use a similar existing
function and edit it.



*****************************
******* Above AAAA **********
*****************************

Above AAAA I believe you can use for anything text.  A good spot to place your
name and stuff.  You probably, don't even have to comment it out.  Since php
only scans the sections between the letters and reads it in.  Also, a
function changelog would be appropriate here.



*****************************
*** Between AAAA and BBBB ***
*****************************

This script is cut and placed in drawimage.php.  The comments are placed in
help.php, but as long as you keep the comments // double backslash, you
probably need not worry about them.

This is the GD function used to draw a point on the screen.  The upper comments
are important, between the "AAAAA" and the word "function" only use //
comments.  These lines will show up as help in the GUI.  Much easier and cleaner
than using docbook.

Next comes the GD function.  Use standard GD code to put the object
on the screen. By convention the define point ($x,$y) must be at the end of the
attributes to allow deleting in the editor and to prevent it from being deleted
by the editor. It is also best not to use non-scalable GD functions like "LINE",
but use "RECT" instead.  You should attempt to make all objects scalable.  Also,
by convention, all objects that use more than one point, should use
coordinates relative to $x,$y.  This will be necessary if I ever make a
"movearea" routine in the menu.  The standard format for a function is,
functionfoo(usually $image or $time first, whatever, blaha, blahb, blahc,
$scale,$x, $y). At minimum you need to include a blank function
"function whatever(blaha, blahb,blahc) {}", if the object was developed for
3-D povray and not to be visible in 2D.

AAAAAAAAAAAAAAAAAAAAAA
//
//  Draws a simple pixel, click point and submit.
//  Color option may be added later.
//  The pixel is only 1 unit high in povray though
//
function pixelone($image, $scale, $x, $y)
{
    $edge = ImageColorAllocate($image,110,190,190);
    $padobe = ImageColorAllocate($image,100,180,180);
    $x = $x * $scale;
    $y = $y * $scale;
    ImageFilledRectangle($image,$x,$y,$x+$scale,$y+$scale,$padobe);
    ImageRectangle($image,$x,$y,$x+$scale,$y+$scale,$edge);
}
BBBBBBBBBBBBBBBBBBBBBBB



*******************************
*** Between BBBBB and CCCCC ***
*******************************

This script is cut and placed in scriptmaker.php.

Between BBBBB and CCCCC is the scriptmaker function.  This function takes data
from the 2nd form and is used to write one line into a text object image file
(.tob). The first thing you need to do is VERIFY the data.  This is very
important if you were use this program online. I am working on verify all data
of all objects, since I was originally not expecting to use the program online
but am now. 'fwrite ($a, $xp)' writes the line to the file.  $PObj contains
the function name, $PDir contains data from the first select box, $PLen contains
data from the second select box, and $PTxt, contains data from the textarea.

BBBBBBBBBBBBBBBBBBBBBBB
if ($PObj == "pixelone") {
    $a=fopen("./files/$pfilez", "a");
    for($i = 0;$i < $PLen; ++$i) {
        if ($PDir == "R") {
            $xp = "<\?php $PObj (\$image,\$scale,$xx,$yy); \?>\n";
            $xx++;
        } else {
            $xp = "\n";
            $yy++;
        }
        fwrite($a, $xp);
    }
    fclose($a);
}
CCCCCCCCCCCCCCCCCCCCCCCCCC



*******************************
*** Between CCCCC and DDDDD ***
*******************************

This script is cut and placed in pov.php.

Between CCCCC and DDDDD is the povray function.  It writes lines
of povray text to a file.  At minimum, even if
you don't use a povray with this object, you need to include one line,
"function whatever(bhaha, blahb, blahc) {}" so if you decide to display
the picture in povray, you won't get an error.  The global variables
are used so you can change the default texture or even floor height.
See falkenstein.tob as an example.  These variables could be placed
in the function, but to save time, of not having to enter textures
for each object it was done this way.  You can change default textures
at the bottom of pov.php.

CCCCCCCCCCCCCCCCCCCCCCCCCCCC
function pixelone($image,$scale,$x,$y)
{
    global $floor;
    global $twall;
    global $tfoundation;
    global $zz;
    $a = "box{<";
    $a .= $x . "," . ($floor) . ",";
    $a .= $y  . "><";
    $a .= $x+1;
    $a .= "," . (1+$floor) . ",";
    $a .= $y+1;
    $a .= "> $twall}\n";
    fwrite($zz,$a);
}
DDDDDDDDDDDDDDDDDDDDDDDDDDDDD



*******************************
*** Between DDDDD and EEEEE ***
*******************************

This script is cut and place in second.php a complicated javascript menu for
index.php.

This is where you setup the menu form. These items are to to generate javascript
menus dynamically.  $inthemenu variable is set to "yes"if you wrote a
scriptmaker function (See above).  You might also want to turn it off on the web
for whatever reason, thus it is an option.$dirlist shows up in the first select
box, $lenlist shows up in the second box, and $txtitem will show up in the
textbox to give the user the format of this box for example "122323&23&12121&Eat
at Joes".  By convention use & to separate data and describe the contents for this
box in the data.

DDDDDDDDDDDDDDDDDDDDDDDDDDDDD
$inthemenu = "yes";
$dirlist = array("R","D");
$lenlist = array("1","2","3","4","5","6","7","8","10","12","16","20","25","30");
$txtitem="";
EEEEEEEEEEEEEEEEEEEEEEEEEEEEE