# UOX3 Script Engine

### Functions, Methods, Properties and Event handling

### Initial A Gump

new Gump
Prototype |
    -
Purpose | Creates a blank gump with no information, allocating memory
Example of Usage |
    var myGump = new Gump;

### Gump Related Methods

AddBackground
Prototype |
    void AddBackground( topHeight, topLeft, bottomHeight, bottomLeft, backImage );
Purpose | Adds a background (should come REALLY early in gump) of height (bottomHeight - topHeight) and width (bottomLeft - topLeft) as image backImage (gump image like via AddGump).
Example of Usage |
    myGump.AddBackground( 0, 0, 320, 340, 2600 );

AddButton
Prototype |
    void AddButton( topHeight, topLeft, buttonImage, (buttonPressedImage), unk1, unk2, unk3 );
Purpose | Adds a button to the gump
Other info | Having an unk1 of 1 indicates the gump will close. unk2 should be the button's unique ID, and unk3 is the page the button will call. buttonPressedImage is optional, and without it a value of buttonImage + 1 is assumed. When the button is pressed, onGumpPress event is called, iButton is 0 if the gump has been closed without pressing a button. function onGumpPress( Sock, iButton ) { }
Example of Usage |
    myGump.AddButton( 13, 290, 5050, 1, 1, 1 );

AddButtonTileArt
Prototype |
    void AddButtonTileArt( topHeight, topLeft, buttonImage, buttonPressedImage, unk1, unk2, unk3, tileID, hue, tileX, tileY );
Purpose | Adds a button to the gump, with tileArt as part of the button
Other info | Having an unk1 of 1 indicates the gump will close. unk2 is the page it will call, while unk3 is the button's unique ID. tileID is tileArt added as part of the button, hue is the tileArt hue, and tileX and tileY is the tileArt's offset compared to the topHeight, topLeft coordinates When the button is pressed, onGumpPress event is called, iButton is 0 if the gump has been closed without pressing a button. function onGumpPress( Sock, iButton ) { }
Example of Usage |
    myGump.AddButtonTileArt( 13, 290, 5050, 5050, 1, 1, 1, 1193, 0, 10, 10 );

AddPageButton
Prototype |
    void AddPageButton( topHeight, topLeft, buttonImage, (buttonPressedImage), pageNum );
Purpose | Adds a button to the gump allowing you to navigate pages without an onGumpPress event. buttonPressedImage is optional, and without it a value of buttonImage + 1 is assumed.
Example of Usage |
    myGump.AddPageButton( 13, 290, 5050, 1 );

AddCheckbox
Prototype |
    void AddCheckbox( topHeight, topLeft, checkImage, defaultStatus, unk2 );
Purpose | Adds a checkbox to the gump
Other info | defaultStatus is true/false to determine the starting status of the checkbox, either checked or not. I believe that unk2 is the checkbox's ID. Uses same IDs as radiobuttons.
Example of Usage |
    myGump.AddCheckbox( 10, 10, 2706, 0, 1 );

AddCroppedText
Prototype |
    void AddCroppedText( left, top, hue, width, height, actualText );
Purpose | Crops the text if it's too long to display properly. Adds scrollbar?
Other info | I believe that unk2 is the checkbox's ID
Example of Usage |
    myGump.AddCroppedText( 10, 10, 0x0342, 300, 200, "Default Text" );

AddCheckerTrans
Prototype |
    void AddCheckerTrans( left, top, width, height );
Purpose | Turns everything underneath the specified area transparent.
Example of Usage |
    myGump.AddCheckerTrans( 0, 0, 300, 220 );

AddGroup
Prototype |
    void AddGroup( groupNum );
Purpose | For grouping sets of radio buttons
Example of Usage |
    myGump.AddGroup( 1 );

AddGump
Prototype |
    void AddGump( topHeight, topLeft, gumpImage );
Purpose | Adds a gump on the current gump (ie any image in the gumps part of InsideUO).
Example of Usage |
    myGump.AddGump( 5, 260, 1141 );

AddGumpColor
Prototype |
    void AddGumpColor( topHeight, topLeft, gumpImage, hue );
Purpose | Adds a gump on the current gump (ie any image in the gumps part of InsideUO). Same as AddGump, but with an additional parameter for hue/color.
Example of Usage |
    myGump.AddGump( 5, 260, 1141, 1154 );

AddPage
Prototype |
    void AddPage( pageNum );
Purpose | Adds a new page
Other info | Anything on page 0 is shown on ALL pages
Example of Usage |
    myGump.AddPage( 1 );

AddPicture
Prototype |
    void AddPicture( topHeight, topLeft, tilePic );
Purpose | Adds the image tilePic to the gump at topHeight/topLeft. tilePic is an ITEM ID.
Example of Usage |
    myGump.AddPicture( 5, 111, 0x0EED );

AddPictureColor
Prototype |
    void AddPictureColor( topHeight, topLeft, tilePic, hue );
Purpose | Adds the image tilePic to the gump at topHeight/topLeft, with color hue. tilePic is an ITEM ID.
Example of Usage |
    myGump.AddPictureColor( 5, 111, 0x0EED, 1154 );

AddRadio
Prototype |
    void AddRadio( topHeight, topLeft, radioImage, pressed, id );
Purpose | Adds a radio button to the gump.
Other info | pressed (0/1) determines the default state of the radiobutton, id is the radiobutton's buttonID. Uses same IDs as CheckBoxes.
Example of Usage |
    myGump.AddRadio( 13, 40, 2151, 0, 2966 );

AddText
Prototype |
    void AddText( topHeight, topLeft, textColour, text );
Purpose | Adds the text text to the gump represented by gumpHandle at topHeight/topLeft in textColour.
Other info | Note that each AddText line automaticly gets assigned a "TextID", starting with 0 and counting upwards for each new AddText line. When using both AddText and AddTextEntry in the same gump, be sure to put all the AddText lines FIRST, then the AddTextEntry lines - since they both use TextIDs and otherwise the automatic assignment will get messed up (or some such)..
Example of Usage |
    myGump.AddText( 30, 30, 0, "Test text" );

AddTextEntry
Prototype |
    void AddTextEntry( topHeight, topLeft, width, height, hue, unk4, textID, defaultText );
Purpose | It adds a text entry with default text to the gump
Other info | unk4 is..? seems to work when set to 1. textID uses an ID which is also automaticly assigned to any AddText line, so be sure to place all AddTextEntry lines after any AddText lines, then assign these with the proper textIDs starting with the next free ID that hasn't been assigned as an ID for an AddText line..
Example of Usage |
    myGump.AddTextEntry( 20, 62, 200, 20, 10, 1, 1, "Default text" );

AddTextEntryLimited
Prototype |
    void AddTextEntryLimited( topHeight, topLeft, width, height, hue, unk4, textID, defaultText, maxLength );
Purpose | It adds a text entry with default text to the gump
Other info | unk4 is..? seems to work when set to 1. textID uses an ID which is also automaticly assigned to any AddText line, so be sure to place all AddTextEntry lines after any AddText lines, then assign these with the proper textIDs starting with the next free ID that hasn't been assigned as an ID for an AddText line.. maxLength specifies max amount of text that can be entered
Example of Usage |
    myGump.AddTextEntryLimited( 20, 62, 200, 20, 10, 1, 1, "Default text", 20 );

AddTiledGump
Prototype |
    void AddTiledGump( left, top, width, height, gumpID );
Purpose | Tiles specified gump within specified area
Other info |
Example of Usage |
    myGump.AddTiledGump( left, top, width, height, gumpID );

AddToolTip
Prototype |
    void AddToolTip( clilocNum );
Purpose | Adds a cliloc-based tooltip to the gump-element added prior to AddToolTip
Other info | -
Example of Usage |
    myGump.AddPicture( 175, 50, 3644 );
    myGump.AddToolTip( 1015094 ); //adds tooltip with cliloc 1015094 to the gump-picture added on the previous line

AddXMFHTMLGump
Prototype |
    void AddXMFHTMLGump( left, top, width, height, number, hasBorder, hasScrollbar );
Purpose | ????
Other info |
Example of Usage |
    myGump.AddXMFHTMLGump( 10, 10, 200, 300, 1, 1, 1 );

AddXMFHTMLGumpColor
Prototype |
    void AddXMFHTMLGumpColor( left, top, width, height, number, hasBorder, hasScrollbar, rgbColour );
Purpose | The purpose of this is to load a HTML like gump using the cliloc "number". Its to do with Localisation settings etc.
Other info |
Example of Usage |
    myGump.AddXMFHTMLGumpColor( 10, 10, 200, 300, 1, 1, 1, ?? );

AddXMFHTMLTok
Prototype |
    void AddXMFHTMLTok( left, top, width, height, hasBorder, hasScrollbar, rgbColour, clilocNum, clilocArg1, clilocArg2, clilocArg3  );
Purpose | The purpose of this is to load a HTML like gump using the cliloc "number". Its to do with Localisation settings etc. (Any of) the three cliloc-arguments are optional, but there must minimum be however many the cliloc requires.
Other info |
Example of Usage |
    myGump.AddXMFHTMLTok( 10, 10, 200, 300, 1, 1, 1, 1060656, 99 );
    myGump.AddXMFHTMLTok( 10, 10, 200, 300, 1, 1, 1, 1060658, 99, "BottlesOfBeer" );
    myGump.AddXMFHTMLTok( 10, 10, 200, 300, 1, 1, 1, 1041522, 99, "BottlesOfBeer", "onTheWall" );

AddHTMLGump
Prototype |
    void AddHTMLGump( topHeight, topLeft, width, height, background, scrollbar, HTMLText);
Purpose | ????
Other info | background and scrollbar either 0 or 1, for respectively off/on. HTMLText is the text in the gump, can use HTML here. Supported tags:
    <B></B> <BIG></BIG> <SMALL></SMALL> <EM></EM> <I></I> <U></U>
    <H1></H1> <H2></H2> <H3></H3> <H4></H4> <H5></H5> <H6></H6> <a href=""></a>
    <div align="right"><div align="left"></DIV> <left></left> <P> <CENTER></CENTER> <BR></BR> <BASEFONT color=#ffffff size=1-7></BASEFONT>
Example of Usage |
    myGump.AddHTMLGump( 10, 10, 200, 300, 1, 1, "This is a test" );

Free
Prototype |
    void Free();
Purpose | Deletes all the memory allocated to the gump
Example of Usage |
    myGump.Free();

NoClose
Prototype |
    void NoClose();
Purpose | This gump can't be closed
Other info | -
Example of Usage |
    myGump.NoClose();

NoDispose
Prototype |
    void NoDispose();
Purpose | Gump cannot be closed through client's "Close Dialogs"-macro
Other info | -
Example of Usage |
    myGump.NoDispose();

NoMove
Prototype |
    void NoMove();
Purpose | This gump can't be moved
Other info | -
Example of Usage |
    myGump.NoMove();

NoResize
Prototype |
    void NoResize();
Purpose | This gump can't be resized
Other info | -
Example of Usage |
    myGump.NoResize();

Send
Prototype |
    void Send( targSocket );
Purpose | Sends the gump to targSocket
Example of Usage |
    myGump.send( mySock );

GumpExample
    function onUseChecked( pUser, iUsed )
    {
    	var myGump = new Gump; // create a new gump
    	myGump.AddBackground( 0, 0, 300, 300, 2600 ); // add an automic scaled background
    	myGump.AddCheckerTrans( 0, 0, 100, 100 ); // Let's make part of the gump transparent! Whee!
    	myGump.AddButton( 300, 5, 0xa50, 1, 0, 0);  // Add a close-gump button
    	myGump.AddGump( 120, 40, 0x157E ); // add some gump art
    	myGump.AddPicture( 20, 40, 0x12D8 ); // add tile art
    	myGump.AddText( 100, 20, 5, "My first gump!" ); // add text, gets assigned TextID 0
    	myGump.AddText( 100, 95, 7, "Some more text!" ); // add text, gets assigned TextID 1
    	myGump.AddText( 20, 200, 7, "TextEntry 1[                ]" ); // add text, gets assigned TextID 2
    	myGump.AddText( 20, 220, 7, "TextEntry 2[                ]" ); // add text, gets assigned TextID 3
    	myGump.AddTextEntry( 100, 200, 120, 25, 10, 0, 4, "First Entry" ); //TextID 4
    	myGump.AddTextEntry( 100, 220, 120, 25, 10, 0, 5, "Second Entry" ); //TextID 5
    	myGump.AddRadio( 20, 130, 2152, 0, 0 ); //RadioButton with ID 0
    	myGump.AddRadio( 20, 150, 2152, 0, 1 ); //RadioButton with ID 1
    	myGump.AddCheckbox( 20, 175, 2706, 0, 2 ); //CheckBox with ID 2
    	myGump.AddButton( 160, 265, 0xF7, 1, 0, 1 ); // add the "okay" button
    	myGump.Send( pUser.socket ); // send this gump to client now
    	myGump.Free(); // clear this gump from uox-memory
    	return false;
    }

    function onGumpPress( pSock, pButton, gumpData )
    {
    	var pUser = pSock.currentChar;
    	switch(pButton)
    	{
    		case 0:
    			// abort and do nothing
    			break;
    		case 1:
    			var Text1 = gumpData.getEdit(0);
    			pUser.SysMessage( "The first TextEntry was: "+Text1 );
    			var Text2 = gumpData.getEdit(1);
    			pUser.SysMessage( "The second TextEntry was: "+Text2 )
    			var OtherButton = gumpData.getButton(0);
    			switch( OtherButton )
    			{
    				case 0:
    					pUser.SysMessage( "You selected RadioButton number: "+OtherButton );
    					pUser.DoAction( 15 );
    					break;
    				case 1:
    					pUser.SysMessage( "You selected RadioButton number: "+OtherButton );
    					pUser.DoAction( 11 );
    					break;
    				case 2:
    					pUser.SysMessage( "The Checkbox with ID "+OtherButton+" was checked." );
    					pUser.DoAction( 18 );
    					break;
    			}
    			break;
    	}
    }

Original: ©Copyright 2000-2001 WWW.UOX3.NET (Daniel Stratton/Matthew Randall)||| Rewrite: ©Copyright 2002 WWW.UOXDEV.DE (Florian "Rukus" Frick)