Tukaram
Member
I have several quests (not mine) that use an item to combine other items to create a new item, it also deletes the component items. An old fisherman quest looks for 10 worms, 1 empty jar, and 1 fertile dirt. It creates a full jar, and deletes all 12 component items. I used that script as my guide.
I am trying to make an empty jar become a full jar, but I want to use these 3 items: 1 empty jar, 5 FireflyTails, and 5 GlowingOoze. The copied code does compile and the item is made. It checks for 5 of both items, plus one jar. If you are missing anything, you get the warning message. If you have 5 of the items it creates the new item - BUT - the delete does not work right. It deletes 1 item c, 5 of item a, and only deletes 1 of item b. So it leaves you with 4 of item b, instead of deleting them. The integer bit seems to be off. I tried a few things but nothing else seems to even compile, because I obviously do not know what I am doing ha ha.
I guess I could just use 1 jar, 1 ooze, and 5 tails... but I want to figure out what I am doing wrong. There must be a way to have it delete all the items.
The next 2 snippets are attempts to correct it, but I get errors. On the first I simply tried to add the to item b. Then I tried to add a new "for(int i=0;i<5;i++)" to both item a & b. Both give errors (as shown below).
________________________________________________________________________________________________
// delete the first 5 of them
for(int i=0;i<5;i++)
a.Delete();
b.Delete();
c.Delete();
****
Errors:
+ Customs/_Testing/Dragon Lantern Quest/Items/GlowingGlassBottleEmpty.cs:
CS0103: Line 50: The name 'i' does not exist in the current context
_________________________________________________________________________________________________
// delete the first 5 of them
for(int i=0;i<5;i++)
a.Delete();
for (int i = 0; i < 5; i++)
b.Delete();
c.Delete();
****
Errors:
+ Customs/_Testing/Dragon Lantern Quest/Items/GlowingGlassBottleEmpty.cs:
CS0021: Line 51: Cannot apply indexing with [] to an expression of type 'Ite
m'
I am trying to make an empty jar become a full jar, but I want to use these 3 items: 1 empty jar, 5 FireflyTails, and 5 GlowingOoze. The copied code does compile and the item is made. It checks for 5 of both items, plus one jar. If you are missing anything, you get the warning message. If you have 5 of the items it creates the new item - BUT - the delete does not work right. It deletes 1 item c, 5 of item a, and only deletes 1 of item b. So it leaves you with 4 of item b, instead of deleting them. The integer bit seems to be off. I tried a few things but nothing else seems to even compile, because I obviously do not know what I am doing ha ha.
I guess I could just use 1 jar, 1 ooze, and 5 tails... but I want to figure out what I am doing wrong. There must be a way to have it delete all the items.
Semi-working code:
public override void OnDoubleClick( Mobile m )
{
Item[] a = m.Backpack.FindItemsByType(typeof(FireflyTails));
// are there at least 5 elements in the returned array?
if ( a!= null && a.Length >= 5)
{
Item b = m.Backpack.FindItemByType(typeof(GlowingOoze));
if (b != null && a.Length >= 5)
{
Item c = m.Backpack.FindItemByType(typeof(GlowingGlassBottleEmpty));
if ( c != null )
{
// delete the first 5 of them
for(int i=0;i<5;i++)
a[i].Delete();
b.Delete();
c.Delete();
// and add the full bottle
m.AddToBackpack(new GlowingGlassBottleFull());
m.SendMessage("The jar is full, hurry back to xxx for your reward!");
}
}
}
else
{
m.SendMessage( "Something went wrong. Are you sure you have everything?" );
}
}
The next 2 snippets are attempts to correct it, but I get errors. On the first I simply tried to add the to item b. Then I tried to add a new "for(int i=0;i<5;i++)" to both item a & b. Both give errors (as shown below).
________________________________________________________________________________________________
// delete the first 5 of them
for(int i=0;i<5;i++)
a.Delete();
b.Delete();
c.Delete();
****
Errors:
+ Customs/_Testing/Dragon Lantern Quest/Items/GlowingGlassBottleEmpty.cs:
CS0103: Line 50: The name 'i' does not exist in the current context
_________________________________________________________________________________________________
// delete the first 5 of them
for(int i=0;i<5;i++)
a.Delete();
for (int i = 0; i < 5; i++)
b.Delete();
c.Delete();
****
Errors:
+ Customs/_Testing/Dragon Lantern Quest/Items/GlowingGlassBottleEmpty.cs:
CS0021: Line 51: Cannot apply indexing with [] to an expression of type 'Ite
m'