# 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, unk1, unk2, unk3 );
Purpose | Adds a button to the gump
Other info | I believe that having an unk1 of 1 indicates the gump will close. unk2 should be the button's unique ID, and I *think* that unk3 is the page it is on. 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 );

AddPageButton
Prototype |
    void AddPageButton( topHeight, topLeft, buttonImage, pageNum );
Purpose | Adds a button to the gump allowing you to navigate pages without an onGumpPress event.
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 | ???
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 );

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 );

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" );

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 );

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. Not sure if theres any real use for it in player run shards, unless you can some how edit the cliloc files in the UO directory
Other info |
Example of Usage |
    myGump.AddXMFHTMLGumpColor( 10, 10, 200, 300, 1, 1, 1, ?? );

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.
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 | ???
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)