Sorry folks . . I have been working on this for over a week but now I am stumped. It's hopefully a nice idea and gold sink if I can get it working.
I'm trying to make an Addon that is a small Planter Box. When a player DBL clicks on it they get a Gump. The Gump lets them select a Plant type to be added (or changed if they already picked one) in the Planter Box and then select what Hue they want for the plant.
I have the Addon and the Gump created but I can't get the Gump Buttons to work on the 'specific' AddonComponent in the Addon to make the required changes.
Here is the last of the endless errors that have been plaguing me on this:
And . . here is my script (in progress):
If any one can turn a light on for me here I would appreciate it.
*bows*
I'm trying to make an Addon that is a small Planter Box. When a player DBL clicks on it they get a Gump. The Gump lets them select a Plant type to be added (or changed if they already picked one) in the Planter Box and then select what Hue they want for the plant.
I have the Addon and the Gump created but I can't get the Gump Buttons to work on the 'specific' AddonComponent in the Addon to make the required changes.
Here is the last of the endless errors that have been plaguing me on this:
Code:
Errors:
+ Customs/PlanterBoxes/StonePlanterBoxAddon.cs:
CS1061: Line 275: 'Server.Items.StonePlanterBoxAddon' does not contain a definition for 'AddonComponent' and no extension method 'AddonComponent' accepting a first argument of type 'Server.Items.StonePlanterBoxAddon' could be found (are you missing a using directive or an assembly reference?)
CS1061: Line 277: 'Server.Items.StonePlanterBoxAddon' does not contain a definition for 'AddonComponent' and no extension method 'AddonComponent' accepting a first argument of type 'Server.Items.StonePlanterBoxAddon' could be found (are you missing a using directive or an assembly reference?)
CS1061: Line 278: 'Server.Items.StonePlanterBoxAddon' does not contain a definition for 'AddonComponent' and no extension method 'AddonComponent' accepting a first argument of type 'Server.Items.StonePlanterBoxAddon' could be found (are you missing a using directive or an assembly reference?)
Code:
using System;
using Server;
using Server.Items;
using Server.Gumps;
using Server.Multis;
using Server.Regions;
using Server.Mobiles;
using Server.Network;
using System.Collections;
using System.Collections.Generic;
namespace Server.Items
{
public class StonePlanterBoxAddon : BaseAddon
{
public override BaseAddonDeed Deed
{
get
{
return new StonePlanterBoxAddonDeed();
}
}
[Constructable]
public StonePlanterBoxAddon() : base()
{
AddonComponent ac;
//West Wall
ac = new AddonComponent( 50 ); //West Wall
AddComponent( ac, 0, 1, 0 );
ac.Name = "Planter Box";
//East Wall
ac = new AddonComponent( 50 ); //East Wall
AddComponent( ac, 1, 1, 0 );
ac.Name = "Planter Box";
//North Wall
ac = new AddonComponent( 49 ); //North Wall
AddComponent( ac, 1, 0, 0 );
ac.Name = "Planter Box";
//South Wall
ac = new AddonComponent( 49 ); //South Wall
AddComponent( ac, 1, 1, 0 );
ac.Name = "Planter Box";
//North Post
ac = new AddonComponent( 48 ); //North Post
AddComponent( ac, 0, 0, 0 );
ac.Name = "Planter Box";
//Dirt
ac = new AddonComponent( 12791 ); //Dirt
AddComponent( ac, 1, 1, 5 );
ac.Name = "Planter Box";
//Dirt Hued Diamond
AddComponent( new PlantBit(this, 3878 ), 1, 1, 6 );
}
public override void OnComponentUsed(AddonComponent ac, Mobile from)
{
if ( from.InRange( this.GetWorldLocation(), 2 ) )
{
if ( ! from.HasGump(typeof(PlanterBoxGump)) )
{
from.SendGump(new PlanterBoxGump(this));
return;
}
}
else
{
from.SendMessage( "You are too far away." );
}
}
public StonePlanterBoxAddon( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // Version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public class PlantBit : AddonComponent
{
private StonePlanterBoxAddon m_plantbit;
[CommandProperty( AccessLevel.GameMaster )]
public StonePlanterBoxAddon plantbit
{
get{ return m_plantbit; }
set{}
}
public PlantBit( StonePlanterBoxAddon plantbit, int itemid ) : base( itemid )
{
m_plantbit = plantbit;
m_plantbit.Name = "Plant Bit";
}
public PlantBit( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( m_plantbit );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch( version )
{
case 0: {
m_plantbit = reader.ReadItem() as StonePlanterBoxAddon;
break;
}
}
}
}
//GUMP BEGINS HERE *************************
private class PlanterBoxGump : Gump
{
private StonePlanterBoxAddon m_PlantBox;
public PlanterBoxGump(StonePlanterBoxAddon plantbox) : base( 20, 20 )
{
m_PlantBox = plantbox;
Closable = true;
Disposable = true;
Dragable = true;
Resizable = false;
//Page 1 = PLANT TYPES MENU ******************
AddPage(1);
AddBackground(2, 0, 350, 525, 9270);
AddLabel(126, 23, 1000, @"Select Plant Type");
AddLabel(105, 60, 1000, @"Bamboo");
AddLabel(105, 100, 1000, @"Blade");
AddLabel(105, 140, 1000, @"Cactus");
AddLabel(105, 180, 1000, @"Campion");
AddLabel(105, 220, 1000, @"Century");
AddLabel(105, 260, 1000, @"Cotton");
AddLabel(105, 300, 1000, @"Elephant");
AddLabel(105, 340, 1000, @"Fern");
AddLabel(105, 380, 1000, @"Foxgrove");
AddLabel(105, 420, 1000, @"Juniper");
AddButton(85, 63, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(85, 103, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(85, 143, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(85, 183, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(85, 223, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(85, 263, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(85, 303, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(85, 343, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(85, 383, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(85, 423, 9022, 9022, 0, GumpButtonType.Page, 5);
AddLabel(210, 60, 1000, @"Lillies");
AddLabel(210, 100, 1000, @"Orfluer");
AddLabel(210, 140, 1000, @"Pampas");
AddLabel(210, 180, 1000, @"Palm");
AddLabel(210, 220, 1000, @"Poppies");
AddLabel(210, 260, 1000, @"Roses");
AddLabel(210, 300, 1000, @"Rushes");
AddLabel(210, 340, 1000, @"Snake Plant");
AddLabel(210, 380, 1000, @"Snowdrops");
AddLabel(210, 420, 1000, @"Spider Tree");
AddButton(190, 63, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(190, 103, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(190, 143, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(190, 183, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(190, 223, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(190, 263, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(190, 303, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(190, 343, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(190, 383, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(190, 423, 9022, 9022, 0, GumpButtonType.Page, 5);
AddButton(146, 475, 242, 243, 1, GumpButtonType.Reply, 0);
//Page 5 = BAMBOO PLANT HUES ****************
AddPage(5);
AddBackground(2, 0, 350, 525, 9270);
AddItem(140, 30, 9325, 0x0); //Bamboo
AddLabel(145, 150, 1000, @"Bamboo Plant");
AddLabel(135, 170, 1000, @"Select Plant Hue");
AddLabel(170, 200, 995, @"Normal");
AddButton(150, 203, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddLabel(100, 225, 81, @"Aqua");
AddLabel(100, 250, 902, @"Black");
AddLabel(100, 275, 92, @"Blue");
AddLabel(100, 300, 95, @"Bright Blue");
AddLabel(100, 325, 71, @"Green");
AddLabel(100, 350, 67, @"BrightGreen");
AddLabel(100, 375, 15, @"Magenta");
AddLabel(100, 400, 1125, @"Orange");
AddLabel(100, 425, 43, @"BrightOrange");
AddButton(80, 228, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(80, 253, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(80, 278, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(80, 303, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(80, 328, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(80, 353, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(80, 378, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(80, 403, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(80, 428, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddLabel(225, 225, 25, @"Pink");
AddLabel(225, 250, 214, @"Purple");
AddLabel(225, 275, 115, @"BrightPurple");
AddLabel(225, 300, 1171, @"Red");
AddLabel(225, 325, 33, @"BrightRed");
AddLabel(225, 350, 1258, @"FireRed");
AddLabel(225, 375, 2212, @"Yellow");
AddLabel(225, 400, 2259, @"BrightYellow");
AddLabel(225, 425, 1153, @"White");
AddButton(205, 228, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(205, 253, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(205, 278, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(205, 303, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(205, 328, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(205, 353, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(205, 378, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(205, 403, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(205, 428, 9022, 9022, 501, GumpButtonType.Reply, 0);
AddButton(146, 477, 2468, 2467, 0, GumpButtonType.Page, 1);//Previous
}
// . . . More Pages Will Follow
//RESPONSE BUTTONS **************************
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = state.Mobile;
if (info.ButtonID == 1) //QUIT
{
from.SendMessage("You decided not to do any gardening at this time.");
from.CloseGump(typeof(PlanterBoxGump));
return;
}
//PAGE 5 RESPONSES (Buttons 500 to 519) *****
if (info.ButtonID == 501) //No Special Hue
{
if (m_PlantBox.AddonComponent.PlantBit.ItemID == 3878)
{
m_PlantBox.AddonComponent.PlantBit.ItemID = 9325;
m_PlantBox.AddonComponent.PlantBit.Hue = 81;
from.SendMessage("Got Inside.");
}
from.SendMessage("A new plant springs to life.");
}
}
}
}
// . . . More Buttons Will Follow
//ADDON DEED ********************************
public class StonePlanterBoxAddonDeed : BaseAddonDeed
{
public override BaseAddon Addon
{
get
{
return new StonePlanterBoxAddon();
}
}
[Constructable]
public StonePlanterBoxAddonDeed()
{
Name = "Stone Planter Box";
}
public StonePlanterBoxAddonDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // Version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
}
*bows*