Clock work assembly

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Clock work assembly

Post by dragon slayer »

Here is what i have done in the function i have made but not working way i want it to.

Code: Select all

function onUseChecked ( pUser, iUsed ) 
{
		// remove one dough
		var iMakeResource = pUser.ResourceCount( 0x103D );	// is there enough resources to use up to make it
		if( iMakeResource < 1 )
		{
			pUser.SysMessage( "You don't seem to have any dough!" );
			return;
		}
                else

		   pUser.UseResource( 1, 0x103D ); // uses up a resource (amount, item ID, item colour)

		// check the skill
		//if( !pUser.CheckSkill( 13, 0, 200 ) )	// character to check, skill #, minimum skill, and maximum skill
		//{
		//	pUser.SysMessage( "You burnt the dough to crisp." );
		//	return;
		//}
		//var itemMade = CreateDFNItem( pUser.socket, pUser, "0x103b", 1, "ITEM", true ); // makes a loaf of bread
		//pUser.SysMessage( "You bake a loaf of bread." );
		return false;
}
What i want to do is

this you double click the item checks to see if you have this items

PowerCrystal
IronIngot
BronzeIngot
Gears

and the amount you need for those items

the amount i need taken from each one of those itsm is

1
50
50
5

well i still don't understand how to make it check for items by id in a fucntion or remove items by a id/color

all i got was code form dough or bread trying to figure it out. any kind of help would rock.
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

At the moment, it doesn't look like we support getting/using resources by name, just by ID or ID/Colour

Code: Select all

function onUseChecked ( pUser, iUsed ) 
{ 
    var numCrystals = pUser.ResourceCount( CRYSTAL_ID );
    var numIngtIron = pUser.ResourceCount( INGOT_ID, IRON_COLOUR );
    var numIngtBrnz = pUser.ResourceCount( INGOT_ID, BRONZE_COLOUR );
    var numGears    = pUser.ResourceCount( GEAR_ID );

    if( numCrystals >= 1 && numIngtIron >= 50 && numIngtBrnz >= 50 && numGears >= 5 )
    {
        pUser.UseResource( 1,  CRYSTAL_ID );
        pUser.UseResource( 50, INGOT_ID, IRON_COLOUR );
        pUser.UseResource( 50, INGOT_ID, BRONZE_COLOUR );
        pUser.UseResource( 5,  GEAR_ID );
        var itemMade = CreateDFNItem( pUser.socket, pUser, your_dfn_item, 1, "ITEM", true ); 
    }
    else
    {
        pUser.SysMessage( "Get more resources, nub" );
    }
}
Something like that, replace IDs/Colours as required.

Attach it to your crafting tool (an anvil, teddy bear, whatever the trigger is)
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

wow that opens a hol;e new world of js to me thank you
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

I have took you script and expanded on it here it is

Code: Select all

function onUseChecked ( pUser, iUsed ) 
{ 
  if( iUsed.container != null )
  {
	var numCrystals = pUser.ResourceCount( 0x1f1c );
    	var numIngtIron = pUser.ResourceCount( 0x1bef, 0x0 );
    	var numIngtBrnz = pUser.ResourceCount( 0x1bef, 0x6D6 );
    	var numGears    = pUser.ResourceCount( 0x1053 );

        if( !pUser.CheckSkill( 37, 600, 600 ) )
	{
	    pUser.SysMessage( "You must have at least 60.0 skill in tinkering to construct a golem." );
            return false;
	}
    	if( numCrystals >= 1 && numIngtIron >= 50 && numIngtBrnz >= 50 && numGears >= 5 ) 
    	{ 
           pUser.UseResource( 1,  0x1f1c ); 
           pUser.UseResource( 50, 0x1bef, 0x0 ); 
           pUser.UseResource( 50, 0x1bef, 0x6D6 ); 
           pUser.UseResource( 5,  0x1053 );  
           pUser.SoundEffect( 0x241, true ); 
           var nSpawned = SpawnNPC( "golem", pUser.x, pUser.y, pUser.z, pUser.worldnumber );
	   nSpawned.owner = pUser;
    	}
    	if ( numCrystals < 1 )
    	{ 
    	   pUser.SysMessage( "You must have a power crystal to construct the golem." );
    	} 
    	if ( numIngtIron < 50 )
    	{ 
     	   pUser.SysMessage( "You must have 50 iron ingots to construct the golem." );
    	} 
    	if ( numIngtBrnz < 50 )
    	{ 
           pUser.SysMessage( "You must have 50 bronze ingots to construct the golem." );
    	} 
    	if ( numGears < 5 )
    	{ 
           pUser.SysMessage( "You must have 5 gears to construct the golem." );
    	} 
   }
   else
	pUser.SysMessage( "That must be in your pack for you to use it." );
    return false;
}
But i am running into a problem

i can't make it give me differant msgs when i don't have the differant resources

as you can see what I'm trying to do here.
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

LOl nevermind i figured it out and what i was doing wrong.
Post Reply