User Tools

Site Tools


own_scripts

Implement my own scripts without touching any original script

It is useful not to change standard Wolfpack files as there can be problems with updating these changed files. So we will create a new directory where we will put our “own” scripts in.

Create "our" directory, files and edit wolfpack.xml

First of all we need a directory to put our scripts in. Let's name this directory “myownscripts”. It should be in the Wolfpack directory.

Now you must edit your “wolfpack.xml”. Search for “<option key=“Definitions””. We must implement our index.xml so Wolfpack can use it. Add it after the standard “index.xml”, so i looks like that:

<option key="Definitions" value="definitions/index.xml;myownscripts/index.xml" />

Python Script

Let's assume you create a script for a skirt which gives the system message “Hello World” when a player double clicks on it. Create a script file in your directory (let's say the name of the file is “skirt.py”). Implement it in your “myownscripts/index.xml”:

<definitions>
    <script>myownscripts.skirt</script>
</definitions>

And your skirt.py looks like this:

def onUse( char, item ):
    char.socket.sysmessage( 'Hello World' )
    return

OK, now we have the script, but the item definition is still missing.

Item definition

We create a file named “skirt.xml” in our “myonwscripts” directory. It contains the definition of our new item.

<definitions>
    <item id="our_skirt" inherit="1531">
        <category>Clothes\Legs\Our Skirt</category>
        <id>0x1516</id>
        <basescripts>equipment,myownscripts.skirt</basescripts>
    </item>
</definitions>

This item has the values of the item with the item id 1531 (skirt, definitions/equipment/clothes.xml) plus our script (the additional <basescripts> tags make it. Be careful: the <basescripts> tag will overwrite all inherited basescripts, so we need to add the “equipment” script, too.).

Now, after reloading the scripts, we can add “our_skirt” and we will get the system message “Hello World” when double clicking it.

own_scripts.txt · Last modified: 2014/03/04 19:51 by thooge