[FIXED] JS Event onPickup exists in code, but is not used by UOX3

Here we stuff all the bugs we've managed to squash/squish/squelch.
Locked
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

JS Event onPickup exists in code, but is not used by UOX3

Post by Xuri »

The situation for onPickup is the same as for onFall - the source for this JS event exists, but it is not referenced anywhere else in UOX3 and thus can't be used in scripts.
Last edited by Xuri on Wed Jul 16, 2008 11:16 pm, edited 2 times in total.
-= Ho Eyo He Hum =-
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

I've added in this hook, but am far too lazy to write a js script to test it. :P

this should be in 0.98-3.7j
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Finally got around to testing this :) The onPickup event fires correctly, but no amount of return false will make the item bounce back to it's original location.
-= Ho Eyo He Hum =-
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

Try return 0 instead of return false. I can't test it at the moment. But I often noticed that the js engine takes "false" as a string, which when being casted into a boolean actually ends up beeing 1 (or true).
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

return 0 gave same result as return false. I.e. item didn't bounce and the player could pick up the item.
-= Ho Eyo He Hum =-
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Fixed on CVS. Return false should now bounce the item back to it's original position.
-= Ho Eyo He Hum =-
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Did some more testing on this, and when the event returns true, the item will always bounce. If the event returns false, the character will be allowed to pick up the item if code allows for it.

Tested using this handy script:

Code: Select all

function onPickup( iPickedUp, pGrabber )
{
	var pSock = pGrabber.socket;

	//Check the value of pSock.pickupSpot to determine where the item was picked up from
	switch( pSock.pickupSpot )
	{
		case 0: //nowhere
			pGrabber.TextMessage( "I picked up this item from... NOWHERE!" );
			break;		
		case 1: //ground
			pGrabber.TextMessage( "I picked up this item from the ground." );
			break;		
		case 2: //ownpack
			pGrabber.TextMessage( "I picked up this item from my own backpack." );
			break;		
		case 3: //otherpack
			pGrabber.TextMessage( "I picked up this item from a container." );
			break;		
		case 4: //paperdoll
			pGrabber.TextMessage( "I picked up this item from my paperdoll." );
			break;		
		case 5: //bank
			pGrabber.TextMessage( "I picked up this item from my bank box." );
			break;
		default:
			pGrabber.TextMessage( "Error. Redo from Start." );
			break;
	}

	return false;
}
It all seems to work, though I'm a little confused as to whether the functionality of return false / return true works as intended, or if it should be the other way around =P
-= Ho Eyo He Hum =-
Locked