# UOX3 Script Engine

### API and Event handling

### Character and Item common functions

ApplySection
Prototype |
    ApplySection( scriptSection );
Purpose | Applies a DFN section to an item/character
Example of Usage |
    object.ApplySection( "orcishlord" );

SetLocation
Prototype |
    SetLocation( short targX, short targY, SCHAR targZ );
Purpose | Moves the object to (targX, targY, targZ )
Example of Usage |
    object.SetLocation( 1000, 1000, 0, 0 );

Teleport
Prototype |
    This method could eiter take 1,2,3 or 4 parameter:
    void Teleport( togoto );
    void Teleport( x, y );
    void Teleport( x, y, z );
    void Teleport( x, y, z, world );
Purpose | In the first Method you need a string, including x, y, z and Worldnumber. NOTE: Anyone exact informations about the string? If you don't give the z-coordinate/worldnumber the actual z-coordinate/worldnumber will be taken. Worldnumber 0=Trammel, Worldnumber 1= Felucca.
Example of Usage |
    myItem.Teleport( 4467, 1284, 5 ); //the object will be sent to moonglow

Delete
Prototype |
    Delete();
Purpose | Delete's the object
Example of Usage |
    object.Delete();

FirstItem
Prototype |
    void FirstItem();
Purpose | Returns a handle to the first item in the container (or multi). If it's null, then there are no items.
Example of Usage |
    function onUseChecked( pUser, iUsed )
    {
    	var mItem;
    	for( mItem = someCont.FirstItem(); !someCont.FinishedItems(); mItem = someCont.NextItem() )
    	{
    		if( mItem != null )
    		{
    			if( mItem.id == 0x0eed ) //Gold, gold, gold!
    				pUser.SysMessage( "I'm carrying "+mItem.amount+" gold coins! I'm rich!" );
    		}
    	}
    }

NextItem
Prototype |
    void NextItem();
Purpose | Returns the next item found in the container (or multi)
Example of Usage |
    SEE ABOVE FUNCTION

FinishedItems
Prototype |
    bool FinishedItems();
Purpose | Returns true if there are no more items left to look through in the container (or multi)
Example of Usage |
    SEE ABOVE FUNCTION

TextMessage
Prototype |
    void TextMessage( message );
    void TextMessage( message, allHear, txtHue );
    void TextMessage( message, allHear, txtHue, speechTarget, speechTargetSerial, speechFontType );
Purpose | The function has 5 extra optional arguments (if including an optional parameter, make sure to also include the preceding argument): allHear (broadcast true/false) txtHue (colour of the text sent to the client) speechTarget (intended target of message. 0 = only visible to sender and receiver, 1 = visible to all players in range, 2 = visible to all NPCs and players in range, 3 = visible to all PCs everywhere + NPCs in range, 4 = visible to all PCs everywhere (broadcast), 5 = only visible to receiver) speechTargetSerial (serial of the receiver of the message, used if speechTarget is 0 or 5) speechFontType (type of font to use. Defaults to normal. 0 = bold, 1 = normal with shadow, 2 = bold with shadow, 3 = normal, 4 = gothic, 5 = italic, 6 = small and dark, 7 = colourful, 8 = runic (only works with CAPS), 9 = small and light)
Example of Usage |
    myChar.TextMessage( "Hello world!" );

    myChar.TextMessage( "Public, ice-coloured message sent to everyone as if I said it.", true, 0x0480 );

    myChar.TextMessage( "Private, ice-coloured message just for me!", false, 0x0480 );
    myItem.TextMessage( "This is a private message from an item to a character!", false, 0, 0, myChar.serial );
    myItem.TextMessage( "THIS IS A MESSAGE IN RUNIC LETTERS VISIBLE TO ALL", true, 0, 3, null, 8 );

DistanceTo
Prototype |
    unsigned short DistanceTo( object );
Purpose | Returns the distance to the object.
Example of Usage |
    mObj.DistanceTo( ourObj );

{p}

GetTag
Prototype |
    tagdata GetTag( "TagName" );
Purpose | Returns the tag with the name TagName stored on Object. Note: The Tags you store on Objects are persistent, that means they're stored in the worldsave. The Tags could contain anything, but you should be careful with storing Character and Item objects in there, better store the Serial returned by GetSerial(...).
Example of Usage |
    var TagValue = myObj.GetTag( "LastObject" );

GetNumTags
Prototype |
    int GetNumTags();
Purpose | Returns the number of Tags assigned to Object. Note: The Tags you store on Objects are persistent, that means they're stored in the worldsave. The Tags could contain anything, but you should be careful with storing Character and Item objects in there, better store the Serial returned by GetSerial(...).
Example of Usage |
    var NumberofTags = mObj.GetNumTags();

SetTag
Prototype |
    void SetTag( "TagName", "TagValue" );
Purpose | Sets a new Value for the Tag called "TagName" on Object. To retrieve this Value use GetTag. Note: If you want to store a value with decimals, you have to store it as a string. Note: The Tags you store on Objects are persistent, that means they're stored in the worldsave. The Tags could contain anything, but you should be careful with storing Character and Item objects in there, better store the Serial returned by GetSerial(...).
Example of Usage |
    var TagValue = "ItWork!"
    mObj.SetTag( "LastObject", TagValue );

StaticEffect
Prototype |
    void StaticEffect( Effect, speed, loop );
Purpose | Does a static effect for a char. NOTE: Anyone got a list of the possible effects?
Example of Usage |
    MyChar.StaticEffect( 0x376A, 9, 6 );

Resist
Prototype |
    int Resist( type );
    void Resist( type, value );
Purpose | Gets and sets the resistance values of a char or item. Types are: Armor Light Water Cold Heat Energy Poison
Example of Usage |
    Set the Armor value of an item to 25:
    mItem.Resist( 1, 25 );

    Get the armor value of an item:
    value = mItem.Resist( 1 );

CanSee
Prototype |
    bool CanSee( object );
    bool CanSee( x, y, z );
Purpose | LineOfSight-checking; check if character/socket can see a specified object/target location
Example of Usage |
    if( !myChar.CanSee( targetChar ))
    	return;

    if( myChar.CanSee( targetChar.x, targetChar.y, targetChar.z )
    {
    	//Do stuff!
    }

KillTimers
Prototype |
    bool Killtimers();

    bool Killtimers( timerID );
Purpose | If no timerID is specified, kills all timers on the object. If timerID is specified, kills only specified timer on object.
Example of Usage |
    // Kills all timers on myObject
    myObject.KillTimers();

    // Kills timer(s) with ID 1 on myObject
    myObject.KillTimers( 1 );

©Copyright 2000-2001 WWW.UOX3.NET (Daniel Stratton/Matthew Randall)