<world>
    <textures>
        <texture name="abstract_a032.jpg">
            <file>/lib/stdtex/bricks.jpg</file>
        </texture>
        <texture name="andrew_wood.jpg">
            <file>/lib/stdtex/my_wood.jpg</file>
        </texture>
        <texture name="chair">
	    <file>/cellib/images/chair5.gif</file>
        </texture>
        <texture name="desk">
	    <file>/cellib/images/desk.png</file>
	    <transparent red="1" green="1" blue="1" />
        </texture>
        <texture name="lamp_desk">
	    <file>/cellib/images/lamp_desk.png</file>
	    <transparent red="1" green="1" blue="1" />
        </texture>
        <texture name="lamp_table">
	    <file>/cellib/images/lamp_table2.gif</file>
	    <transparent red="1" green="1" blue="1" />
        </texture>
        <texture name="table_coffee">
	    <file>/cellib/images/table_coffee5.gif</file>
	    <transparent red="1" green="1" blue="1" />
        </texture>
    </textures>
    <materials>
        <material name="wood"> <texture>andrew_wood.jpg</texture> </material>
        <material name="abstract"> <texture>abstract_a032.jpg</texture> </material>
	<material name="chair"> <texture>chair</texture> </material>
	<material name="desk"> <texture>desk</texture> </material>
	<material name="lamp_desk"> <texture>lamp_desk</texture> </material>
	<material name="lamp_table"> <texture>lamp_table</texture> </material>
	<material name="table_coffee"> <texture>table_coffee</texture> </material>
    </materials>
    <plugins>
        <plugin name="thing">crystalspace.mesh.loader.thing</plugin>
	<plugin name="spr3d">crystalspace.mesh.loader.sprite.3d</plugin>
        <plugin name="celentity">cel.addons.celentity</plugin>
        <plugin name="xmlscripts">cel.addons.xmlscripts</plugin>
    </plugins>

    <addon plugin="xmlscripts">
        <pcfactory>cel.pcfactory.mesh</pcfactory>
        <pcfactory>cel.pcfactory.solid</pcfactory>
        <pcfactory>cel.pcfactory.gravity</pcfactory>
        <pcfactory>cel.pcfactory.movable</pcfactory>
        <pcfactory>cel.pcfactory.billboard</pcfactory>
        <pcfactory>cel.pcfactory.properties</pcfactory>
        <script name="box">
	    <event name="init">
	        <property propclass="pc(pcgravity)"
			id="propid(weight)" value="1.0" />
	        <action propclass="pc(pcgravity)"
			id="actid(ApplyPermanentForce)">
		    <par id="parid(force)" value="[0,-9.8,0]" />
	        </action>
	    </event>
	    <event name="pctimer_start">
	    </event>
	</script>

        <script name="generic_object">
	</script>

        <script name="switch_size">
	    <event name="init">
	        <var name="normal" value="true" />
	        <var name="dxdy" value="int(rand(4.0)-2.0)" />
		<var name="counter" value="0" />
		<print value="'dxdy:'+?dxdy" />
	    </event>

	    <event name="counter_test">
	        <var name="counter" value="?counter+@d" />
		<return value="?counter" />
	    </event>

	    <event name="makesmall">
		<print value="result"/>
	        <call event="counter_test">
		    <par id="parid(d)" value="2" />
		    <return var="result" />
		</call>
		<print value="'result: '+?result" />

	        <var name="normal" value="false" />
		<print value="makesmall" />
	    	<default propclass="pc(pcbillboard)" />
		<var name="w" value="property(propid(width))" />
		<var name="h" value="property(propid(height))" />
	        <property id="propid(width)" value="30000" />
	        <property id="propid(height)" value="30000" />
	    </event>
	    <event name="makelarge">
	        <var name="normal" value="true" />
		<print value="makelarge" />
	        <property propclass="pc(pcbillboard)"
			id="propid(width)" value="?w" />
	        <property propclass="pc(pcbillboard)"
			id="propid(height)" value="?h" />
	    </event>
	    <event name="pcbillboard_select">
	        <if eval="?normal" true="makesmall" false="makelarge" />
	    </event>
	</script>

        <script name="lamp">
	    <event name="init">
	        <var name="isinit" value="false" />
	        <var name="three" value="3.0" />


		<lvar name="i" value="4" />
		<lvar name="j" value="3" />
		<var entity="lamp_desk" name="bla_+#i+'_'+#j" value="'test!X'" />
		<print value="?lamp_desk.bla[#j+1,#i-1]" />
	    </event>
	    <event name="findpc">
	    	<var name="collidetest" value="pc(table_coffee, pcbillboard)" />
	        <var name="isinit" value="true" />
	    </event>
	    <event name="collide">
	        <property propclass="pc(pcbillboard)"
			id="propid(color)" value="rgb(0,0,1)" />
	    </event>
	    <event name="nocollide">
	        <property propclass="pc(pcbillboard)"
			id="propid(color)" value="rgb(1,1,1)" />
	    </event>
	    <event name="pcbillboard_move">
	        <print value="'x:'+param(parid(x))+' y:'+param(parid(y))" />
		<print value="rand(1)" />
	        <if eval="?isinit" false="findpc" />
		<if eval="bb_testcollide(?collidetest)"
			true="collide"
			false="nocollide" />
	    </event>
	</script>
    </addon>

    <sector name="room">
        <meshobj name="room_walls_portal">
            <zfill />
            <plugin>thing</plugin>
            <params>
                <v x="-20" y="-1" z="-20" />
                <v x="-20" y="-1" z="20" />
                <v x="20" y="-1" z="20" />
                <v x="20" y="-1" z="-20" />
                <v x="-20" y="5" z="-20" />
                <v x="-20" y="5" z="20" />
                <v x="20" y="5" z="20" />
                <v x="20" y="5" z="-20" />
                <v x="-20" y="-1" z="-1" />
                <v x="-20" y="-1" z="1" />
                <v x="-1" y="-1" z="20" />
                <v x="1" y="-1" z="20" />
                <v x="20" y="-1" z="1" />
                <v x="20" y="-1" z="-1" />
                <v x="1" y="-1" z="-20" />
                <v x="-1" y="-1" z="-20" />
                <v x="-20" y="5" z="-1" />
                <v x="-20" y="5" z="1" />
                <v x="-1" y="5" z="20" />
                <v x="1" y="5" z="20" />
                <v x="20" y="5" z="1" />
                <v x="20" y="5" z="-1" />
                <v x="1" y="5" z="-20" />
                <v x="-1" y="5" z="-20" />
                <material>abstract</material>
                <texlen>5</texlen>
                <cosfact>0.8</cosfact>
                <p name="front1">
                    <v>5</v>
                    <v>18</v>
                    <v>10</v>
                    <v>1</v>
                </p>
                <p name="front2_portal">
                    <v>18</v>
                    <v>19</v>
                    <v>11</v>
                    <v>10</v>
                </p>
            </params>
        </meshobj>
        <meshobj name="room_walls">
            <zfill />
            <plugin>thing</plugin>
            <params>
                <v x="-20" y="-1" z="-20" />
                <v x="-20" y="-1" z="20" />
                <v x="20" y="-1" z="20" />
                <v x="20" y="-1" z="-20" />
                <v x="-20" y="5" z="-20" />
                <v x="-20" y="5" z="20" />
                <v x="20" y="5" z="20" />
                <v x="20" y="5" z="-20" />
                <v x="-20" y="-1" z="-1" />
                <v x="-20" y="-1" z="1" />
                <v x="-1" y="-1" z="20" />
                <v x="1" y="-1" z="20" />
                <v x="20" y="-1" z="1" />
                <v x="20" y="-1" z="-1" />
                <v x="1" y="-1" z="-20" />
                <v x="-1" y="-1" z="-20" />
                <v x="-20" y="5" z="-1" />
                <v x="-20" y="5" z="1" />
                <v x="-1" y="5" z="20" />
                <v x="1" y="5" z="20" />
                <v x="20" y="5" z="1" />
                <v x="20" y="5" z="-1" />
                <v x="1" y="5" z="-20" />
                <v x="-1" y="5" z="-20" />
                <material>abstract</material>
                <texlen>5</texlen>
                <cosfact>0.8</cosfact>
                <p name="down1">
                    <v>0</v>
                    <v>1</v>
                    <v>10</v>
                    <v>15</v>
                    <material>wood</material>
                    <texmap>
                        <orig x="0" y="-1" z="0" />
                        <first x="1" y="-1" z="0" />
                        <firstlen>5</firstlen>
                        <second x="0" y="-1" z="1" />
                        <secondlen>5</secondlen>
                    </texmap>
                </p>
                <p name="down2">
                    <v>15</v>
                    <v>10</v>
                    <v>11</v>
                    <v>14</v>
                    <material>wood</material>
                    <texmap>
                        <orig x="0" y="-1" z="0" />
                        <first x="1" y="-1" z="0" />
                        <firstlen>5</firstlen>
                        <second x="0" y="-1" z="1" />
                        <secondlen>5</secondlen>
                    </texmap>
                </p>
                <p name="down3">
                    <v>14</v>
                    <v>11</v>
                    <v>2</v>
                    <v>3</v>
                    <material>wood</material>
                    <texmap>
                        <orig x="0" y="-1" z="0" />
                        <first x="1" y="-1" z="0" />
                        <firstlen>5</firstlen>
                        <second x="0" y="-1" z="1" />
                        <secondlen>5</secondlen>
                    </texmap>
                </p>
                <p name="up1">
                    <v>5</v>
                    <v>4</v>
                    <v>23</v>
                    <v>18</v>
                    <material>wood</material>
                    <texmap>
                        <orig x="0" y="5" z="0" />
                        <first x="1" y="5" z="0" />
                        <firstlen>5</firstlen>
                        <second x="0" y="5" z="1" />
                        <secondlen>5</secondlen>
                    </texmap>
                </p>
                <p name="up2">
                    <v>18</v>
                    <v>23</v>
                    <v>22</v>
                    <v>19</v>
                    <material>wood</material>
                    <texmap>
                        <orig x="0" y="5" z="0" />
                        <first x="1" y="5" z="0" />
                        <firstlen>5</firstlen>
                        <second x="0" y="5" z="1" />
                        <secondlen>5</secondlen>
                    </texmap>
                </p>
                <p name="up3">
                    <v>19</v>
                    <v>22</v>
                    <v>7</v>
                    <v>6</v>
                    <material>wood</material>
                    <texmap>
                        <orig x="0" y="5" z="0" />
                        <first x="1" y="5" z="0" />
                        <firstlen>5</firstlen>
                        <second x="0" y="5" z="1" />
                        <secondlen>5</secondlen>
                    </texmap>
                </p>
                <p name="front3">
                    <v>19</v>
                    <v>6</v>
                    <v>2</v>
                    <v>11</v>
                </p>
                <p name="back1">
                    <v>7</v>
                    <v>22</v>
                    <v>14</v>
                    <v>3</v>
                </p>
                <p name="back2">
                    <v>22</v>
                    <v>23</v>
                    <v>15</v>
                    <v>14</v>
                </p>
                <p name="back3">
                    <v>23</v>
                    <v>4</v>
                    <v>0</v>
                    <v>15</v>
                </p>
                <p name="right1">
                    <v>6</v>
                    <v>20</v>
                    <v>12</v>
                    <v>2</v>
                </p>
                <p name="right2">
                    <v>20</v>
                    <v>21</v>
                    <v>13</v>
                    <v>12</v>
                </p>
                <p name="right3">
                    <v>21</v>
                    <v>7</v>
                    <v>3</v>
                    <v>13</v>
                </p>
                <p name="left1">
                    <v>4</v>
                    <v>16</v>
                    <v>8</v>
                    <v>0</v>
                </p>
                <p name="left2">
                    <v>16</v>
                    <v>17</v>
                    <v>9</v>
                    <v>8</v>
                </p>
                <p name="left3">
                    <v>17</v>
                    <v>5</v>
                    <v>1</v>
                    <v>9</v>
                </p>
            </params>
        </meshobj>
	<meshobj name="box">
	    <file>/cellib/objects/box</file>
	    <plugin>spr3d</plugin>
	    <params>
	        <factory>box</factory>
		<action>default</action>
	    </params>
	    <move>
	        <v x="2" y="2" z="5" />
	    </move>
	    <zuse />
	    <priority>object</priority>
	    <addon plugin="celentity">
		<propclass name="pcsolid" />
		<propclass name="pcgravity" />
		<propclass name="pcmovable" />
	        <behaviour name="box" />
	    </addon>
	</meshobj>

	<addon plugin="celentity" entityname="chair">
	    <propclass name="pcbillboard">
	        <property name="name" string="chair" />
	        <property name="materialname" string="chair" />
	        <property name="clickable" bool="1" />
	        <property name="movable" bool="1" />
	        <property name="restack" bool="1" />
		<property name="color" color="1,0,0" />
	        <property name="widthpct" float=".7" />
	        <property name="heightpct" float=".7" />
	    </propclass>
            <behaviour name="switch_size" />
	</addon>
	<addon plugin="celentity" entityname="desk">
	    <propclass name="pcbillboard">
	        <property name="name" string="desk" />
	        <property name="materialname" string="desk" />
	        <property name="movable" bool="1" />
	        <property name="restack" bool="1" />
	    </propclass>
            <behaviour name="generic_object" />
	</addon>
	<addon plugin="celentity" entityname="lamp_desk">
	    <propclass name="pcbillboard">
	        <property name="name" string="lamp_desk" />
	        <property name="materialname" string="lamp_desk" />
	        <property name="movable" bool="1" />
	        <property name="clickable" bool="1" />
	        <property name="restack" bool="1" />
	        <property name="widthpct" float=".40" />
	        <property name="heightpct" float=".40" />
	        <property name="x" long="160000" />
	        <property name="y" long="160000" />
	    </propclass>
            <behaviour name="lamp" />
	</addon>
	<addon plugin="celentity" entityname="lamp_table">
	    <propclass name="pcbillboard">
	        <property name="name" string="lamp_table" />
	        <property name="materialname" string="lamp_table" />
	        <property name="movable" bool="1" />
	        <property name="clickable" bool="1" />
	        <property name="restack" bool="1" />
	        <property name="widthpct" float=".40" />
	        <property name="heightpct" float=".40" />
	    </propclass>
            <behaviour name="lamp" />
	</addon>
	<addon plugin="celentity" entityname="table_coffee">
	    <propclass name="pcbillboard">
	        <property name="name" string="table_coffee" />
	        <property name="materialname" string="table_coffee" />
	        <property name="movable" bool="1" />
	        <property name="restack" bool="1" />
	    </propclass>
            <behaviour name="generic_object" />
	</addon>

        <light>
            <center x="0" y="0" z="0" />
            <radius>40</radius>
            <color red="1" green="1" blue="1" />
        </light>
    </sector>
</world>

