PigPen

Member
ServUO Version
Publish Unknown
Ultima Expansion
Mondain's Legacy
Hi - Happy New Year!

Is it possible to use 'OnDouble Click' on any part of an Addon#1 (that has multiple AddonComponents) to make it turn into Addon #2 ?
I am hoping something like this could work so players do not have to ReDeed Addon#1 then use a different Deed to get Addon #2.

My reason?
I created an Addon#1 that looks like a TV with a blank black screen and I hope that by DBL Clicking on it players can change it into Addon #2 that has random items displayed over the screen area. The effect I hope to achieve is that of turning the TV on or Turning it off. Each time it would trigger a random display change.

Alternatively . . is it be possible with OnDoubleClick to use only one Addon (not separate ones) and have the various AddonComponents (for the items to be displayed) change from Visible = false to Visible = true when OnDoubleClick is used anywhere on the Addon?

If something like this is possible with Addons that have multiple item AddonComponents then I will attempt it but my skills with something like this are very limited and I anticipate a long line of errors/edit/errors/edit/errors.

I appreciate the community's opinions in something like this.

Many Thanks
 
You can do stuff in the OnComponentUsed, and then check the component being used. Then you would add the items to the addon on used and either set a flag or use the items added if detected or double-clicked, to turn it back off by having it remove the items from the addon.
 
Thank you Dramoor for your time looking at this for me and for your suggestion.

I have no doubt your idea is the correct path to follow and I have spent hours trying to make it work for me. My biggest problem is searching the various component parts to see which ones exist so I can decide what to add (when the TV is turned on) and what to delete (when the TV is turned off).

To get it working I have tried adding a 'head' hues 33 (red) when the frame of the TV is used . . then deleted when the frame of the TV is used while the head exists.

After countless tries and failures . . here are my current errors:
Code:
 + Customs/GM Addons/TVEastWithPicAddon.cs:
    CS1502: Line 94: The best overloaded method match for 'Server.Items.AddonComponent.AddonComponent(int)' has some invalid arguments
    CS1503: Line 94: Argument 1: cannot convert from 'Server.Items.FlatScreenTvEastAddon' to 'int'

And . . here is my current script:
Code:
using System;
using Server;
using Server.Items;
using System.Collections;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;
using Server.Multis;
using Server.Targeting;
using Server.Mobiles;

namespace Server.Items
{

    public class FlatScreenTvEastAddon : BaseAddon
    {
        public override BaseAddonDeed Deed
        {
            get
            {
                return new FlatScreenTvEastAddonDeed();
            }
        }

        [ Constructable ]
        public FlatScreenTvEastAddon()
        {

    // TV Background and Frame (ALL GREY):
            AddComplexComponent( (BaseAddon) this, 419, -1, -1, 16, 2106, -1, "4K Flat Screen Frame", 1);// 1 Side Frame 'Grey'
            AddComplexComponent( (BaseAddon) this, 419, -1, 1, 16, 2106, -1, "4K Flat Screen Frame", 1);// 2 Side Frame 'Grey'

            AddComplexComponent( (BaseAddon) this, 417, -1, 1, 13, 2106, -1, "4K Flat Screen Frame", 1);// 3 Top Frame 'Grey'
            AddComplexComponent( (BaseAddon) this, 417, -1, 0, 13, 2106, -1, "4K Flat Screen Frame", 1);// 4 Top Frame 'Grey'

            AddComplexComponent( (BaseAddon) this, 417, -1, 0, 0, 2106, -1, "4K Flat Screen Frame", 1);// 5 Bottom Frame 'Grey'
            AddComplexComponent( (BaseAddon) this, 417, -1, 1, 0, 2106, -1, "4K Flat Screen Frame", 1);// 6 Bottom Frame 'Grey'

            AddComplexComponent( (BaseAddon) this, 268, -1, 0, 16, 1, -1, "4K Flat Screen", 1);// 7 Background Panel 'Black'
            AddComplexComponent( (BaseAddon) this, 268, -1, 1, 16, 1, -1, "4K Flat Screen", 1);// 8 Background Panel 'Black'
        }

        public FlatScreenTvEastAddon( Serial serial ) : base( serial )
        {
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource)
        {
            AddComplexComponent(addon, item, xoffset, yoffset, zoffset, hue, lightsource, null, 1);
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
        {
            AddonComponent ac;
            ac = new AddonComponent(item);
            if (name != null && name.Length > 0)
                ac.Name = name;
            if (hue != 0)
                ac.Hue = hue;
            if (amount > 1)
            {
                ac.Stackable = true;
                ac.Amount = amount;
            }
            if (lightsource != -1)
                ac.Light = (LightType) lightsource;

            addon.AddComponent(ac, xoffset, yoffset, zoffset);
        }

        public virtual bool CanUseFromHouse{ get{ return true; } }

        private readonly FlatScreenTvEastAddon _fstv;

        public override void OnComponentUsed(AddonComponent ac, Mobile from)
        {
            BaseHouse house = BaseHouse.FindHouseAt( this );

            if ( house != null && !house.IsOwner( from ) )
            {
                from.SendMessage( "You do not own this." );
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("You are too far away.");
                return;
            }

//Problems begin here:

            AddonComponent achead;
            achead = new AddonComponent(this);
            achead.ItemID = 7916;

//***************************

        //Check if TV Frame was 'used':

            if ( (ac.ItemID == 417) || (ac.ItemID == 419) ) 
            {

        //If item to be displayed (a head) does not exist add it

                if ( achead == null)
                {
                    AddComplexComponent( (BaseAddon) this, 7916, 1, 1, 34, 33, -1, "head", 1);
                    from.SendMessage( "You turn the TV on" );
                    return;
                }

        //Otherwise if the item (a head) exists then remove it
                else
                {
                    if ( achead != null)
                    {
                        achead.Delete();
                        from.SendMessage( "You turn the TV off" );
                        return;
                    }
                }
            }
//***************************

        }

        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 FlatScreenTvEastAddonDeed : BaseAddonDeed
    {
        public override BaseAddon Addon
        {
            get
            {
                return new FlatScreenTvEastAddon();
            }
        }

        [Constructable]
        public FlatScreenTvEastAddonDeed()
        {
            Name = "Flat Screen East. Use Frame to Turn On";
        }

        public FlatScreenTvEastAddonDeed( 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();
        }
    }
}

My limited abilities just can't create a list of existing Addoncomponents to determine if something should be added or deleted.

Sorry to be a pain but I'm hoping someone might know how this can be done.

Many Thanks
 
ok are you just trying to get it to change the itemids when double clicking on it? if so there is a way to do it.
If you look at my glass furnace look at how the closeid works. the first ids are the closedids and the second ids are the ones showing the fired up ids when its been double clicked so if you had more than one component you just use same id for things that dont change and change only the ones that you want changed in the second ids.
furnace:
using System;
using Server;
using Server.Gumps;
using Server.Network;

namespace Server.Items
{
    public class FurnaceComponent : AddonComponent
    {
        public override int LabelNumber { get { return 1036362; } } // a glass furnace
       
        private int m_ClosedID;

        [CommandProperty( AccessLevel.GameMaster )]
        public int ClosedID
        {
            get { return m_ClosedID; }
            set { m_ClosedID = value; }
        }

        public FurnaceComponent( int itemID, int closedID ) : base( itemID )
        {
            m_ClosedID = closedID;
        }

        public FurnaceComponent( Serial serial ) : base( serial )
        {
        }

        public override void OnDoubleClick( Mobile from )
        {
            base.OnDoubleClick( from );

            if ( Addon != null )
            {
                if ( from.InRange( Location, 1 ) )
                {
                    foreach ( AddonComponent f in Addon.Components )
                    {
                        if ( f is FurnaceComponent )
                        {
                            FurnaceComponent furnace = (FurnaceComponent) f;

                            int temp = furnace.ItemID;
                            furnace.ItemID = furnace.ClosedID;
                            furnace.ClosedID = temp;
                            from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1095405 ); // You light the furnace.
                        }
                    }
                }
                else
                    from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
            }
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.WriteEncodedInt( 0 ); // version

            writer.Write( (int) m_ClosedID );
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadEncodedInt();

            m_ClosedID = reader.ReadInt();
        }
    }

    public class GlassFurnaceAddon : BaseAddon
    {
        public override BaseAddonDeed Deed{ get{ return new GlassFurnaceDeed(); } }
       
        [Constructable]
        public GlassFurnaceAddon( bool east ) : base()
        {
            Name = "a glass furnace";

            if ( east ) // east
            {
                AddComponent( new FurnaceComponent( 0xBC9E, 0xBC9F ), 0, 0, 0 );
            }
            else         // south
            {
                AddComponent( new FurnaceComponent( 0xBC9A, 0xBC9B ), 0, 0, 0 );
            }
        }

        public GlassFurnaceAddon( Serial serial ) : base( serial )
        {
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.WriteEncodedInt( 0 ); // version
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadEncodedInt();
        }
    }
 
Hello Vert-I-Go

I started this project with a basic addon that looked like a Flat Screen TV with a blank screen. It is composed of two short wall pieces hued black for the Screen and surrounded by Primitive Wood pieces hued Grey to look like the Frame for the Screen.

It then Occurred to me . . it would be nice to be able to DoubleClick on the Frame and have other items added as addon components with hues that would show up against the black Screen background.

The 'long game' for me if I get that solved would then be to have the DoubleClick on the Frame result in one or more of six random item addons appearing with random hues so players would have some variety and maintained interest in the TV.

This is why Dramoor's suggestion of using the 'OnComponentUsed' method held such appeal for me. So far I can get it to add an item over the Screen but have not been able to remove it by a second DoubleClick on the Frame or change its ItemID or Hue.
 
OK let's look at this from a different standpoint. Do you want items added or items already in the addon to be changed? I ask this because do you have the addon of what u wanted with the items on too? So then I can see the offsets to show you the best code for this that I would use.
Here I did some code and put an example in here for ya of one way to do it.


C#:
    public class FlatScreenTvEastAddon : BaseAddon
    {
        public override BaseAddonDeed Deed
        {
            get
            {
                return new FlatScreenTvEastAddonDeed();
            }
        }

        [Constructable]
        public FlatScreenTvEastAddon()
        {

            // TV Background and Frame (ALL GREY):
            AddComplexComponent((BaseAddon)this, 419, -1, -1, 16, 2106, -1, "4K Flat Screen Frame", 1);// 1 Side Frame 'Grey'
            AddComplexComponent((BaseAddon)this, 419, -1, 1, 16, 2106, -1, "4K Flat Screen Frame", 1);// 2 Side Frame 'Grey'

            AddComplexComponent((BaseAddon)this, 417, -1, 1, 13, 2106, -1, "4K Flat Screen Frame", 1);// 3 Top Frame 'Grey'
            AddComplexComponent((BaseAddon)this, 417, -1, 0, 13, 2106, -1, "4K Flat Screen Frame", 1);// 4 Top Frame 'Grey'

            AddComplexComponent((BaseAddon)this, 417, -1, 0, 0, 2106, -1, "4K Flat Screen Frame", 1);// 5 Bottom Frame 'Grey'
            AddComplexComponent((BaseAddon)this, 417, -1, 1, 0, 2106, -1, "4K Flat Screen Frame", 1);// 6 Bottom Frame 'Grey'

            AddComplexComponent((BaseAddon)this, 268, -1, 0, 16, 1, -1, "4K Flat Screen", 1);// 7 Background Panel 'Black'
            AddComplexComponent((BaseAddon)this, 268, -1, 1, 16, 1, -1, "4K Flat Screen", 1);// 8 Background Panel 'Black'
        }

        public FlatScreenTvEastAddon(Serial serial) : base(serial)
        {
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource)
        {
            AddComplexComponent(addon, item, xoffset, yoffset, zoffset, hue, lightsource, null, 1);
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
        {
            AddonComponent ac;
            ac = new AddonComponent(item);
            if (name != null && name.Length > 0)
                ac.Name = name;
            if (hue != 0)
                ac.Hue = hue;
            if (amount > 1)
            {
                ac.Stackable = true;
                ac.Amount = amount;
            }
            if (lightsource != -1)
                ac.Light = (LightType)lightsource;

            addon.AddComponent(ac, xoffset, yoffset, zoffset);
        }

        public virtual bool CanUseFromHouse { get { return true; } }

        private readonly FlatScreenTvEastAddon _fstv;

        public override void OnComponentUsed(AddonComponent ac, Mobile from)
        {
            BaseHouse house = BaseHouse.FindHouseAt(this);

            if (house != null && !house.IsOwner(from))
            {
                from.SendMessage("You do not own this.");
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("You are too far away.");
                return;
            }

            if(TurnedOn(this, 7916))
            {
                TurnOff(from, this, 7916);

            }
            else
            {
                AddComplexComponent((BaseAddon)this, 7916, 1, 1, 34, 33, -1, "head", 1);
                from.SendMessage("You turn the TV on");
                return;
            }

        }

        public virtual bool TurnedOn(BaseAddon addon, int itemid)
        {
            bool ison = false;
            foreach (AddonComponent abc in addon.Components)
            {
                if (abc.ItemID == itemid)
                {
                    ison = true;
                    break;
                }
            }

            return ison;
        }


        public virtual void TurnOff(Mobile from, BaseAddon addon, int itemid)
        {
            AddonComponent component = null;

            if (addon == null || addon.Deleted)
                return;

            for (int i = 0; i < addon.Components.Count; i++)
            {
                AddonComponent ac = addon.Components[i];

                if (ac != null && !ac.Deleted && ac.ItemID == itemid)
                {
                    component = ac;
                    break;
                }
            }

            if(component != null && !component.Deleted)
            {
                if (addon.Components.Contains(component))
                {
                    addon.Components.Remove(component);
                    component.Addon = null;
                    component.Delete();
                    from.SendMessage("You turn the TV off");
                }
            }
        }
        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 FlatScreenTvEastAddonDeed : BaseAddonDeed
    {
        public override BaseAddon Addon
        {
            get
            {
                return new FlatScreenTvEastAddon();
            }
        }

        [Constructable]
        public FlatScreenTvEastAddonDeed()
        {
            Name = "Flat Screen East. Use Frame to Turn On";
        }

        public FlatScreenTvEastAddonDeed(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();
        }
    }
 
Last edited:
Hey Dramoor

Well first off . . just Wow! That sample is close to perfect and has been really great working with. It Adds/Displays/Removes the item perfectly and functionally exactly what I was looking to achieve.

I was able to display the item (head) with random Hues so it changed fairly often giving the impression of changing channels.

Where I run into problems is when I try to add and remove more than one item. For example if I want to add the 'head' just off to one side a bit then add a second item beside the 'head' . . . the two items get added perfectly but then . . only the 'head' gets removed.

To make this project really interesting for players I would like to be able to add two or three items then have them all removed when the TV is turned off.

I am not sure how to make the script search for all the items added when the TV is turned on so it can remove all of those new items when it is turned off.

Accomplishing that would let me display the head with something else one time and another time display a fireworks show etc. I would only want to display a maximum of three items at any one time due to the limited screen space.

Here is my latest try which includes adding multiple items. That part works (thanks to you), but only the 'head' gets removed when turned off.
Code:
using System;
using Server;
using Server.Items;
using System.Collections;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;
using Server.Multis;
using Server.Targeting;
using Server.Mobiles;

namespace Server.Items
{
    public class FlatScreenTvEastAddon : BaseAddon
    {
        public override BaseAddonDeed Deed
        {
            get
            {
                return new FlatScreenTvEastAddonDeed();
            }
        }

        [ Constructable ]
        public FlatScreenTvEastAddon()
        {
            // TV Screen - Hued Black:
            AddComplexComponent( (BaseAddon) this, 268, 0, 0, 2, 1, -1, "4k Flat Screen", 1);// 1
            AddComplexComponent( (BaseAddon) this, 268, 0, 1, 2, 1, -1, "4k Flat Screen", 1);// 2

            // TV Frames Sides - Hued Grey:
            AddComplexComponent( (BaseAddon) this, 64, 0, -1, 1, 2106, -1, "Frame", 1);// 3
            AddComplexComponent( (BaseAddon) this, 64, 0, 1, 2, 2106, -1, "Frame", 1);// 4
            // TV Frames Top Bottom - Hued Grey:
            AddComplexComponent( (BaseAddon) this, 81, 0, 0, 12, 2106, -1, "Frame", 1);// 5
            AddComplexComponent( (BaseAddon) this, 81, 0, 1, 12, 2106, -1, "Frame", 1);// 6
            AddComplexComponent( (BaseAddon) this, 81, 0, 1, 0, 2106, -1, "Frame", 1);// 7
            AddComplexComponent( (BaseAddon) this, 81, 0, 0, 0, 2106, -1, "Frame", 1);// 8
        }

        public FlatScreenTvEastAddon( Serial serial ) : base( serial )
        {
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource)
        {
            AddComplexComponent(addon, item, xoffset, yoffset, zoffset, hue, lightsource, null, 1);
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
        {
            AddonComponent ac;
            ac = new AddonComponent(item);
            if (name != null && name.Length > 0)
                ac.Name = name;
            if (hue != 0)
                ac.Hue = hue;
            if (amount > 1)
            {
                ac.Stackable = true;
                ac.Amount = amount;
            }
            if (lightsource != -1)
                ac.Light = (LightType) lightsource;
            addon.AddComponent(ac, xoffset, yoffset, zoffset);
        }

        public virtual bool CanUseFromHouse { get { return true; } }

        public override void OnComponentUsed(AddonComponent ac, Mobile from)
        {
            BaseHouse house = BaseHouse.FindHouseAt(this);

            if (house != null && !house.IsOwner(from))
            {
                from.SendMessage("You do not own this.");
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("You are too far away.");
                return;
            }

            if(TurnedOn(this, 7916))
            {
                TurnOff(from, this, 7916);
            }
            else
            {

        //Add Displayed Items Here:

                switch ( Utility.Random( 5 ) )
                {
            //Head and Galaxy:
                    case 0: AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 0, -1, "4K Flat Screen", 1);
                AddComplexComponent( (BaseAddon) this, 10984, 1, 1, 11, 1102, -1, "4K Flat Screen", 1); break;
                    case 1: AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 33, -1, "4K Flat Screen", 1);
                AddComplexComponent( (BaseAddon) this, 10984, 1, 1, 11, 1089, -1, "4K Flat Screen", 1); break;
                    case 2: AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 59, -1, "4K Flat Screen", 1);
                AddComplexComponent( (BaseAddon) this, 10984, 1, 1, 11, 1089, -1, "4K Flat Screen", 1); break;
                    case 3: AddComplexComponent((BaseAddon)this, 7916, 1, 0, 9, 59, -1, "4K Flat Screen", 1);
                AddComplexComponent( (BaseAddon) this, 10984, 1, 1, 12, 2951, -1, "4K Flat Screen", 1); break;
                    case 4: AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 91, -1, "4K Flat Screen", 1);
                AddComplexComponent( (BaseAddon) this, 10984, 1, 1, 12, 1099, -1, "4K Flat Screen", 1); break;
                }
                from.SendMessage("You turn the TV on");
                return;
            }
        }

        public virtual bool TurnedOn(BaseAddon addon, int itemid)
        {
            bool ison = false;
            foreach (AddonComponent abc in addon.Components)
            {
                if (abc.ItemID == itemid)
                {
                    ison = true;
                    break;
                }
            }
            return ison;
        }

        public virtual void TurnOff(Mobile from, BaseAddon addon, int itemid)
        {
            AddonComponent component = null;

            if (addon == null || addon.Deleted)
                return;

        //Remove Displayed Items Here:

            for (int i = 0; i < addon.Components.Count; i++)
            {
                AddonComponent ac = addon.Components[i];

                if (ac != null && !ac.Deleted && ac.ItemID == itemid)
                {
                    component = ac;
                    break;
                }
            }

            if(component != null && !component.Deleted)
            {
                if (addon.Components.Contains(component))
                {
                    addon.Components.Remove(component);
                    component.Addon = null;
                    component.Delete();
                    from.SendMessage("You turn the TV off");
                }
            }
        }

        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 FlatScreenTvEastAddonDeed : BaseAddonDeed
    {
        public override BaseAddon Addon
        {
            get
            {
                return new FlatScreenTvEastAddon();
            }
        }

        [Constructable]
        public FlatScreenTvEastAddonDeed()
        {
            Name = "Flat Screen East. Use Frame to Turn On";
        }

        public FlatScreenTvEastAddonDeed( 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();
        }
    }
}

I can't tell you how much your help on this is appreciated and I look forward to any guidance you might have to make this one complete.

Many Thanks
*bows*
 
Last edited:
So I gave an example earlier to do with one ItemID in the setting just to show a different way for a basic example while showing it. You could directly put all the ItemIDs into the code. But here I just moved where the turn-off message went and added a second turn-off with the other ItemID. This should work as well.


C#:
    public class FlatScreenTvEastAddon : BaseAddon
    {
        public override BaseAddonDeed Deed
        {
            get
            {
                return new FlatScreenTvEastAddonDeed();
            }
        }

        [Constructable]
        public FlatScreenTvEastAddon()
        {

            // TV Background and Frame (ALL GREY):
            AddComplexComponent((BaseAddon)this, 419, -1, -1, 16, 2106, -1, "4K Flat Screen Frame", 1);// 1 Side Frame 'Grey'
            AddComplexComponent((BaseAddon)this, 419, -1, 1, 16, 2106, -1, "4K Flat Screen Frame", 1);// 2 Side Frame 'Grey'

            AddComplexComponent((BaseAddon)this, 417, -1, 1, 13, 2106, -1, "4K Flat Screen Frame", 1);// 3 Top Frame 'Grey'
            AddComplexComponent((BaseAddon)this, 417, -1, 0, 13, 2106, -1, "4K Flat Screen Frame", 1);// 4 Top Frame 'Grey'

            AddComplexComponent((BaseAddon)this, 417, -1, 0, 0, 2106, -1, "4K Flat Screen Frame", 1);// 5 Bottom Frame 'Grey'
            AddComplexComponent((BaseAddon)this, 417, -1, 1, 0, 2106, -1, "4K Flat Screen Frame", 1);// 6 Bottom Frame 'Grey'

            AddComplexComponent((BaseAddon)this, 268, -1, 0, 16, 1, -1, "4K Flat Screen", 1);// 7 Background Panel 'Black'
            AddComplexComponent((BaseAddon)this, 268, -1, 1, 16, 1, -1, "4K Flat Screen", 1);// 8 Background Panel 'Black'
        }

        public FlatScreenTvEastAddon(Serial serial) : base(serial)
        {
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource)
        {
            AddComplexComponent(addon, item, xoffset, yoffset, zoffset, hue, lightsource, null, 1);
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
        {
            AddonComponent ac;
            ac = new AddonComponent(item);
            if (name != null && name.Length > 0)
                ac.Name = name;
            if (hue != 0)
                ac.Hue = hue;
            if (amount > 1)
            {
                ac.Stackable = true;
                ac.Amount = amount;
            }
            if (lightsource != -1)
                ac.Light = (LightType)lightsource;

            addon.AddComponent(ac, xoffset, yoffset, zoffset);
        }

        public virtual bool CanUseFromHouse { get { return true; } }

        private readonly FlatScreenTvEastAddon _fstv;

        public override void OnComponentUsed(AddonComponent ac, Mobile from)
        {
            BaseHouse house = BaseHouse.FindHouseAt(this);

            if (house != null && !house.IsOwner(from))
            {
                from.SendMessage("You do not own this.");
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("You are too far away.");
                return;
            }

            if(TurnedOn(this))
            {
                TurnOff(from, this, 7916);
                TurnOff(from, this, 10984);
                from.SendMessage("You turn the TV off");
            }
            else
            {

                //Add Displayed Items Here:
                switch (Utility.Random(5))
                {
                    //Head and Galaxy:
                    case 0:
                        AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 0, -1, "4K Flat Screen", 1);
                        AddComplexComponent((BaseAddon)this, 10984, 1, 1, 11, 1102, -1, "4K Flat Screen", 1); break;
                    case 1:
                        AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 33, -1, "4K Flat Screen", 1);
                        AddComplexComponent((BaseAddon)this, 10984, 1, 1, 11, 1089, -1, "4K Flat Screen", 1); break;
                    case 2:
                        AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 59, -1, "4K Flat Screen", 1);
                        AddComplexComponent((BaseAddon)this, 10984, 1, 1, 11, 1089, -1, "4K Flat Screen", 1); break;
                    case 3:
                        AddComplexComponent((BaseAddon)this, 7916, 1, 0, 9, 59, -1, "4K Flat Screen", 1);
                        AddComplexComponent((BaseAddon)this, 10984, 1, 1, 12, 2951, -1, "4K Flat Screen", 1); break;
                    case 4:
                        AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 91, -1, "4K Flat Screen", 1);
                        AddComplexComponent((BaseAddon)this, 10984, 1, 1, 12, 1099, -1, "4K Flat Screen", 1); break;
                }
                from.SendMessage("You turn the TV on");
                return;
            }

        }

        public virtual bool TurnedOn(BaseAddon addon)
        {
            bool ison = false;
            foreach (AddonComponent abc in addon.Components)
            {
                if (abc.ItemID == 7916 || abc.ItemID == 10984)
                {
                    ison = true;
                    break;
                }
            }

            return ison;
        }


        public virtual void TurnOff(Mobile from, BaseAddon addon, int itemid)
        {
            AddonComponent component = null;

            if (addon == null || addon.Deleted)
                return;

            for (int i = 0; i < addon.Components.Count; i++)
            {
                AddonComponent ac = addon.Components[i];

                if (ac != null && !ac.Deleted && ac.ItemID == itemid)
                {
                    component = ac;
                    break;
                }
            }

            if (component != null && !component.Deleted)
            {
                if (addon.Components.Contains(component))
                {
                    addon.Components.Remove(component);
                    component.Addon = null;
                    component.Delete();
                }
            }
        }

        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 FlatScreenTvEastAddonDeed : BaseAddonDeed
    {
        public override BaseAddon Addon
        {
            get
            {
                return new FlatScreenTvEastAddon();
            }
        }

        [Constructable]
        public FlatScreenTvEastAddonDeed()
        {
            Name = "Flat Screen East. Use Frame to Turn On";
        }

        public FlatScreenTvEastAddonDeed(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();
        }
    }


This should work. Should be good. Although looks like u moved the Z axis on the items and they sit farther from the tv now.
 
Last edited:
Again Dramoor . . thank you for the insight.

Yes I made changes to the various axis (X.Y.Z) because the way I had them originally prevented a player from placing the item from a deed inside their house unless they were on the roof. The way is is now, the upper floors are not blocking the placement and parts of the display are not appearing in the room above.

That all said . . . your latest example works perfectly for my project. You have opened a whole new world for me with Addons.

I am in your debt not only for your skill but also for your time and prompt replies.

Thank you Dramoor . . greatly appreciated.

*bows*
 
I am hoping for one last bit of help to improve this new Addon.

As it was:
- Using 'any' of the Component parts would toggle the Screen on or off.
- Players would have to toggle the Screen off then back on again in order to view the next random channel.

So . . I modified the 'Frame' of the TV to include two 'Buttons' on the one side. They have different ItemID numbers and different Hues with the hope that one can be used to turn the TV on/off while the other would allow players to change channels without having to turn the unit off then back on for each channel change.

My dilema is trying to figure out how to make the script react to just the control buttons instead of having it react to any or all of the Component parts.

I have worked on this a lot over the past few days but no luck on this part of the scripting.

Can anyone see how this could be done?

Here is my current script:
Code:
using System;
using Server;
using Server.Items;
using System.Collections;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;
using Server.Multis;
using Server.Targeting;
using Server.Mobiles;

namespace Server.Items
{
    public class FlatScreenTvEastAddon : BaseAddon
    {
        public override BaseAddonDeed Deed
        {
            get
            {
                return new FlatScreenTvEastAddonDeed();
            }
        }

        [ Constructable ]
        public FlatScreenTvEastAddon()
        {
            // TV Screen - Hued Black:
            AddComplexComponent( (BaseAddon) this, 268, 0, 0, 2, 1, -1, "4k Flat Screen", 1);// 1
            AddComplexComponent( (BaseAddon) this, 268, 0, 1, 2, 1, -1, "4k Flat Screen", 1);// 2

            // TV Frame One Side - Hued Grey:
            AddComplexComponent( (BaseAddon) this, 64, 0, -1, 1, 2106, -1, "Frame", 1);// 3
            //AddComplexComponent( (BaseAddon) this, 64, 0, 1, 2, 2106, -1, "Frame", 1);// 4

            // TV Frames Top Bottom - Hued Grey:
            AddComplexComponent( (BaseAddon) this, 81, 0, 0, 12, 2106, -1, "Frame", 1);// 5
            AddComplexComponent( (BaseAddon) this, 81, 0, 1, 12, 2106, -1, "Frame", 1);// 6
            AddComplexComponent( (BaseAddon) this, 81, 0, 1, 0, 2106, -1, "Frame", 1);// 7
            AddComplexComponent( (BaseAddon) this, 81, 0, 0, 0, 2106, -1, "Frame", 1);// 8

            // TV Channel Button - Hued Green:
            AddComplexComponent( (BaseAddon) this, 273, 0, 1, 7, 2702, -1, "Channel Button", 1);// 4

            // TV On/Off Button - Hued Red:
            AddComplexComponent( (BaseAddon) this, 696, 0, 1, 2, 2642, -1, "On/Off Button", 1);// 4

        }

        public FlatScreenTvEastAddon( Serial serial ) : base( serial )
        {
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource)
        {
            AddComplexComponent(addon, item, xoffset, yoffset, zoffset, hue, lightsource, null, 1);
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
        {
            AddonComponent ac;
            ac = new AddonComponent(item);
            if (name != null && name.Length > 0)
                ac.Name = name;
            if (hue != 0)
                ac.Hue = hue;
            if (amount > 1)
            {
                ac.Stackable = true;
                ac.Amount = amount;
            }
            if (lightsource != -1)
                ac.Light = (LightType) lightsource;
            addon.AddComponent(ac, xoffset, yoffset, zoffset);
        }

        public virtual bool CanUseFromHouse { get { return true; } }

        public override void OnComponentUsed(AddonComponent ac, Mobile from)
        {
            BaseHouse house = BaseHouse.FindHouseAt(this);

            if (house != null && !house.IsOwner(from))
            {
                from.SendMessage("You do not own this.");
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("You are too far away.");
                return;
            }

            int firewrk = Utility.RandomList( 1065, 1066, 1082, 1089, 1099, 1071, 1073, 1076, 1102 );

            int firewrks = Utility.RandomList( 1066, 1082, 1089, 1099, 1102, 1088, 1088 );

            if(TurnedOn(this, 7916))
            {
                TurnOff(from, this, 7916); // head east
                TurnOff(from, this, 7897); // head south
                TurnOff(from, this, 10984); // galaxy
                TurnOff(from, this, 15536); // garland south
                TurnOff(from, this, 15542); // garland east
                TurnOff(from, this, 15686); // candles south
                TurnOff(from, this, 15682); // candles east
                TurnOff(from, this, 3676); // rune Y
                TurnOff(from, this, 3679); // rune P
                TurnOff(from, this, 3682); // rune M
                TurnOff(from, this, 3685); // rune F
                TurnOff(from, this, 3688); // rune N
                TurnOff(from, this, 15442); // Small rune F
                TurnOff(from, this, 15448); // Small rune Z
                TurnOff(from, this, 15446); // Small rune T
                TurnOff(from, this, 15445); // Small rune X
                TurnOff(from, this, 15444); // Small rune Y
                TurnOff(from, this, 15443); // Small rune B
                TurnOff(from, this, 15447); // Small rune X
                TurnOff(from, this, 15449); // Small rune Y
                TurnOff(from, this, 3855); // Star Sapphire R
                TurnOff(from, this, 3862); // Amethyst    R
                TurnOff(from, this, 3869); // Ruby        R
                TurnOff(from, this, 3873); // Sapphire    R
                TurnOff(from, this, 3884); // Citrine    R
                TurnOff(from, this, 3887); // Emerald    R
                TurnOff(from, this, 3888); // Diamond    R
                TurnOff(from, this, 3870); // Toumaline    L
                TurnOff(from, this, 3885); // Toumaline    L
                TurnOff(from, this, 14360); // energy
                TurnOff(from, this, 14133); // fizzle
                TurnOff(from, this, 14201); // blue sparkles
                TurnOff(from, this, 10980); // lava small
                TurnOff(from, this, 13401); // lava big
                TurnOff(from, this, 7193); // exploding oil flask
                TurnOff(from, this, 7878); // dropping coins
                TurnOff(from, this, 3555); // campfire
                TurnOff(from, this, 6571); // a fire
                TurnOff(from, this, 14052); // fireball small V
                TurnOff(from, this, 14265); // glow big
                TurnOff(from, this, 14270); // glow small
                TurnOff(from, this, 4390); // mushroom
                TurnOff(from, this, 8903); // Crescent Moon
                TurnOff(from, this, 8099); // water wave Lt to Rt
                TurnOff(from, this, 8113); // water wave Rt to Lt
                TurnOff(from, this, 6686); // Lava Falls E
                TurnOff(from, this, 6691); // Lava Falls E
                TurnOff(from, this, 6696); // Lava Falls E
                TurnOff(from, this, 6701); // Lava Falls E
                TurnOff(from, this, 6706); // Lava Falls E
                TurnOff(from, this, 6732); // Lava Falls S
                TurnOff(from, this, 6737); // Lava Falls S
                TurnOff(from, this, 6742); // Lava Falls S
                TurnOff(from, this, 6747); // Lava Falls S
                TurnOff(from, this, 6752); // Lava Falls S
                TurnOff(from, this, 2557); // candle facing E
                TurnOff(from, this, 2562); // candle facing S
                TurnOff(from, this, 11517); // Sm Beetle S 
                TurnOff(from, this, 11519); // Sm Beetle E 
                TurnOff(from, this, 11523); // Lrg Beetle S
                TurnOff(from, this, 11521); // Lrg Beetle E
                TurnOff(from, this, 7961); // Green Glowing Crystal
                TurnOff(from, this, 7964); // Prple Glowing Crystal
                TurnOff(from, this, 7885); // Green Glowing Crystal
                TurnOff(from, this, 7888); // Red Glowing Crystal
                TurnOff(from, this, 15404); // Necro Pendant
                TurnOff(from, this, 6880); // small skull E
                TurnOff(from, this, 6882); // small skull E
                TurnOff(from, this, 6884); // small skull forward
                TurnOff(from, this, 6881); // small skull S
                TurnOff(from, this, 6883); // small skull S
                TurnOff(from, this, 4341); // evil head
                TurnOff(from, this, 4342); // evil head Animated
                TurnOff(from, this, 4348); // larger evil head    S
                TurnOff(from, this, 4350); // evil head Animated S
                TurnOff(from, this, 6161); // Sand Clock 
                TurnOff(from, this, 3877); // Amber for Sun
                TurnOff(from, this, 4893); // Flower 
                TurnOff(from, this, 4942); // Flower 
                TurnOff(from, this, 4986); // Flower 
                TurnOff(from, this, 4987); // Flower 
                TurnOff(from, this, 4988); // Flower 
                TurnOff(from, this, 4975); // Flower 
                TurnOff(from, this, 6377); // Ginseng Flower
                TurnOff(from, this, 6378); // Ginseng Flower
                TurnOff(from, this, 6809); // Flax Flower
                TurnOff(from, this, 6810); // Flax Flower
                TurnOff(from, this, 9035); // Rose of Trinsic
                TurnOff(from, this, 15459); // Holly Berries
                TurnOff(from, this, 4993); // Mushrooms
                TurnOff(from, this, 5003); // Mushroom 
                TurnOff(from, this, 5001); // Lrg Cherries
                TurnOff(from, this, 5002); // Cherries 
                TurnOff(from, this, 13258); // Tiger Toy
                TurnOff(from, this, 13259); // Wyrm Toy
                TurnOff(from, this, 15101); // Fish
                TurnOff(from, this, 15102); // Fish
                TurnOff(from, this, 15103); // Fish
                TurnOff(from, this, 15104); // Fish
                TurnOff(from, this, 15105); // Fish
                TurnOff(from, this, 15107); // Fish
                TurnOff(from, this, 15108); // Fish
                TurnOff(from, this, 15109); // Fish
                TurnOff(from, this, 15110); // Fish
                TurnOff(from, this, 15111); // Fish
                TurnOff(from, this, 15112); // Fish
                TurnOff(from, this, 15113); // Fish
                TurnOff(from, this, 15114); // Fish
                TurnOff(from, this, 15115); // Fish
                TurnOff(from, this, 7086); // Fish Food

                    from.SendMessage("You turn the TV off");
            }
            //END If Turned ON

            else
            {
                switch ( Utility.Random( 7 ) )
                {
                    case 0: switch ( Utility.Random( 5 ) )
                    {
                    //Head and Galaxy:
                        case 0: AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 0, -1, "4K Flat Screen", 1);
                        AddComplexComponent( (BaseAddon) this, 10984, 1, 1, 11, 1102, -1, "4K Flat Screen", 1); break;
                        case 1: AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 33, -1, "4K Flat Screen", 1);
                        AddComplexComponent( (BaseAddon) this, 10984, 1, 1, 11, 1089, -1, "4K Flat Screen", 1); break;
                        case 2: AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 59, -1, "4K Flat Screen", 1);
                        AddComplexComponent( (BaseAddon) this, 10984, 1, 1, 11, 1089, -1, "4K Flat Screen", 1); break;
                        case 3: AddComplexComponent((BaseAddon)this, 7916, 1, 0, 9, 59, -1, "4K Flat Screen", 1);
                        AddComplexComponent( (BaseAddon) this, 10984, 1, 1, 12, 2951, -1, "4K Flat Screen", 1); break;
                        case 4: AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 91, -1, "4K Flat Screen", 1);
                        AddComplexComponent( (BaseAddon) this, 10984, 1, 1, 12, 1099, -1, "4K Flat Screen", 1); break;
                    } break;
                    case 1: switch ( Utility.Random( 16 ) )
                    {
                    //Head and Energy Wave:
                        case 0: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 0, -1, "4K Flat Screen", 1); break;
                        case 1: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2946, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2946, -1, "4K Flat Screen", 1); break;
                        case 2: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2947, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2947, -1, "4K Flat Screen", 1); break;
                        case 3: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2950, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2950, -1, "4K Flat Screen", 1); break;
                        case 4: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2981, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2981, -1, "4K Flat Screen", 1); break;
                        case 5: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2991, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2991, -1, "4K Flat Screen", 1); break;
                        case 6: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2995, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2995, -1, "4K Flat Screen", 1); break;
                        case 7: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2831, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2831, -1, "4K Flat Screen", 1); break;
                        case 8: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2848, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2848, -1, "4K Flat Screen", 1); break;
                        case 9: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2865, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2865, -1, "4K Flat Screen", 1); break;
                        case 10: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2876, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2876, -1, "4K Flat Screen", 1); break;
                        case 11: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2879, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 91, -1, "4K Flat Screen", 1); break;
                        case 12: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2817, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2817, -1, "4K Flat Screen", 1); break;
                        case 13: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2802, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2802, -1, "4K Flat Screen", 1); break;
                        case 14: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2792, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2792, -1, "4K Flat Screen", 1); break;
                        case 15: AddComplexComponent((BaseAddon)this, 14360, 1, 1, 13, 2779, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7916, 1, 0, 8, 2779, -1, "4K Flat Screen", 1); break;
                    } break;
                    case 2: switch ( Utility.Random( 9 ) )
                    {
                    //Runes and Gems:
                        case 0: AddComplexComponent((BaseAddon)this, 3676, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3855, 1, 1, 12, 0, -1, "4K Flat Screen", 1); break;
                        case 1: AddComplexComponent((BaseAddon)this, 3679, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3888, 1, 1, 17, 0, -1, "4K Flat Screen", 1); break;
                        case 2: AddComplexComponent((BaseAddon)this, 3682, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3888, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3869, 1, 1, 17, 0, -1, "4K Flat Screen", 1); break;
                        case 3: AddComplexComponent((BaseAddon)this, 3888, 1, 1, 17, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3685, 1, 1, 13, 0, -1, "4K Flat Screen", 1); break;
                        case 4: AddComplexComponent((BaseAddon)this, 3688, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3884, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 5: AddComplexComponent((BaseAddon)this, 15442, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 15449, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 15448, 1, 1, 10, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3869, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 7, 0, -1, "4K Flat Screen", 1); break;
                        case 6: AddComplexComponent((BaseAddon)this, 15443, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 15446, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3884, 1, 1, 17, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 5, 0, -1, "4K Flat Screen", 1); break;
                        case 7: AddComplexComponent((BaseAddon)this, 15445, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 15444, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3888, 1, 1, 17, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 4, 0, -1, "4K Flat Screen", 1); break;
                        case 8: AddComplexComponent((BaseAddon)this, 15447, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 15449, 1, 1, 10, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3888, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3870, 1, 0, 9, 0, -1, "4K Flat Screen", 1); break;
                    } break;
                    case 3: switch ( Utility.Random( 8 ) )
                    {
                    //Fireworks:
                        case 0: AddComplexComponent((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 10980, 1, 1, 11, firewrk, -1, "4K Flat Screen", 1); break;
                        case 1: AddComplexComponent((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 10980, 1, 1, 11, firewrk, -1, "4K Flat Screen", 1); break;
                        case 2: AddComplexComponent((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 13401, 1, 1, 11, firewrks, -1, "4K Flat Screen", 1); break;
                        case 3: AddComplexComponent((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 13401, 1, 1, 11, firewrks, -1, "4K Flat Screen", 1); break;
                        case 4: AddComplexComponent((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 14133, 1, 1, 11, firewrks, -1, "4K Flat Screen", 1); break;
                        case 5: AddComplexComponent((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 14133, 1, 1, 11, firewrks, -1, "4K Flat Screen", 1); break;
                        case 6: AddComplexComponent((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7878, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7193, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                        case 7: AddComplexComponent((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7878, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7193, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                    } break;
                    case 4: switch ( Utility.Random( 13 ) )
                    {
                    //Flowers:
                        case 0: AddComplexComponent((BaseAddon)this, 4893, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 1161, -1, "4K Flat Screen", 1); break;
                        case 1: AddComplexComponent((BaseAddon)this, 4942, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 2: AddComplexComponent((BaseAddon)this, 4986, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 3: AddComplexComponent((BaseAddon)this, 4987, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 4: AddComplexComponent((BaseAddon)this, 4988, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 5: AddComplexComponent((BaseAddon)this, 4975, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 6: AddComplexComponent((BaseAddon)this, 6377, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 7: AddComplexComponent((BaseAddon)this, 6378, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 8: AddComplexComponent((BaseAddon)this, 6809, 1, 1, 9, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 9: AddComplexComponent((BaseAddon)this, 4993, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 10: AddComplexComponent((BaseAddon)this, 5003, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 11: AddComplexComponent((BaseAddon)this, 5001, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 12: AddComplexComponent((BaseAddon)this, 5002, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                    } break;
                    case 5: switch ( Utility.Random( 14 ) )
                    {
                    //Fish:
                        case 0: AddComplexComponent((BaseAddon)this, 15101, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 1: AddComplexComponent((BaseAddon)this, 15102, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 2: AddComplexComponent((BaseAddon)this, 15103, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 3: AddComplexComponent((BaseAddon)this, 15105, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 4: AddComplexComponent((BaseAddon)this, 15104, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 5: AddComplexComponent((BaseAddon)this, 15107, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 6: AddComplexComponent((BaseAddon)this, 15113, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 7: AddComplexComponent((BaseAddon)this, 15112, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 8: AddComplexComponent((BaseAddon)this, 15108, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 9: AddComplexComponent((BaseAddon)this, 15109, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 10: AddComplexComponent((BaseAddon)this, 15110, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 11: AddComplexComponent((BaseAddon)this, 15114, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 12: AddComplexComponent((BaseAddon)this, 15111, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 13: AddComplexComponent((BaseAddon)this, 15115, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                    } break;
                    case 6: switch ( Utility.Random( 10 ) )
                    {
                    //Stars and Moon:
                        case 0: AddComplexComponent((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3887, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 7, 0, -1, "4K Flat Screen", 1); break;
                        case 1: AddComplexComponent((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 8, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 6, 0, -1, "4K Flat Screen", 1); break;
                        case 2: AddComplexComponent((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3873, 1, 1, 10, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 4, 0, -1, "4K Flat Screen", 1); break;
                        case 3: AddComplexComponent((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3862, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 4, 0, -1, "4K Flat Screen", 1); break;
                        case 4: AddComplexComponent((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3869, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 4, 0, -1, "4K Flat Screen", 1); break;
                        case 5: AddComplexComponent((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3884, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 4, 0, -1, "4K Flat Screen", 1); break;
                        case 6: AddComplexComponent((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3888, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3870, 1, 0, 7, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                        case 7: AddComplexComponent((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7878, 1, 1, 13, 1161, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3870, 1, 0, 7, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                        case 8: AddComplexComponent((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7878, 1, 1, 13, 1161, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3869, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                        case 9: AddComplexComponent((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 7878, 1, 1, 13, 1161, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3873, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddComplexComponent((BaseAddon)this, 3885, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                    } break;
                }
                from.SendMessage("You turn the TV on");
                return;
            }
        }
//END OnComponent Use

        public virtual bool TurnedOn(BaseAddon addon, int itemid)
        {
            bool ison = false;
            foreach (AddonComponent abc in addon.Components)
            {
                if ( abc.ItemID == 7916 || abc.ItemID == 7897 || abc.ItemID == 10984 || abc.ItemID == 15536 || abc.ItemID == 15542 || abc.ItemID == 14360 || abc.ItemID == 3555 || abc.ItemID == 14265 || abc.ItemID == 14270 || abc.ItemID == 14133 || abc.ItemID == 14201 || abc.ItemID == 14052 || abc.ItemID == 10980 || abc.ItemID == 13401 || abc.ItemID == 4390 || abc.ItemID == 3676 || abc.ItemID == 3679 || abc.ItemID == 3682 || abc.ItemID == 3685 || abc.ItemID == 3688 || abc.ItemID == 15682 || abc.ItemID == 15686 || abc.ItemID == 15442 || abc.ItemID == 15443 || abc.ItemID == 15444 || abc.ItemID == 15445 || abc.ItemID == 15446 || abc.ItemID == 15447 || abc.ItemID == 15448 || abc.ItemID == 15449 || abc.ItemID == 6571 || abc.ItemID == 7193 || abc.ItemID == 8099 || abc.ItemID == 8113 || abc.ItemID == 6686 || abc.ItemID == 6691 || abc.ItemID == 6696 || abc.ItemID == 6701 || abc.ItemID == 6706 || abc.ItemID == 6732 || abc.ItemID == 6737 || abc.ItemID == 6742 || abc.ItemID == 6747 || abc.ItemID == 6752 || abc.ItemID == 2557 || abc.ItemID == 2562 || abc.ItemID == 11517 || abc.ItemID == 11519 || abc.ItemID == 11523 || abc.ItemID == 11521 || abc.ItemID == 7961 || abc.ItemID == 7964 || abc.ItemID == 7885 || abc.ItemID == 7888 || abc.ItemID == 7878 || abc.ItemID == 8903 || abc.ItemID == 3855 || abc.ItemID == 3862 || abc.ItemID == 3869 || abc.ItemID == 3873 || abc.ItemID == 3877 || abc.ItemID == 3884 || abc.ItemID == 3887 || abc.ItemID == 3888 || abc.ItemID == 3870 || abc.ItemID == 3885 || abc.ItemID == 15404 || abc.ItemID == 6880 || abc.ItemID == 6882 || abc.ItemID == 6884 || abc.ItemID == 6881 || abc.ItemID == 6883 || abc.ItemID == 4341 || abc.ItemID == 4342 || abc.ItemID == 4348 || abc.ItemID == 4350 || abc.ItemID == 6161 || abc.ItemID == 4893 || abc.ItemID == 4986 || abc.ItemID == 4987 || abc.ItemID == 4988 || abc.ItemID == 4975 || abc.ItemID == 4942 || abc.ItemID == 6377 || abc.ItemID == 6378 || abc.ItemID == 6809 || abc.ItemID == 6810 || abc.ItemID == 9035 || abc.ItemID == 15459 || abc.ItemID == 4993 || abc.ItemID == 5003 || abc.ItemID == 5001 || abc.ItemID == 5002 || abc.ItemID == 13258 || abc.ItemID == 13259 || abc.ItemID == 15101 || abc.ItemID == 15102 || abc.ItemID == 15103 || abc.ItemID == 15104 || abc.ItemID == 15105 || abc.ItemID == 15107 || abc.ItemID == 15108 || abc.ItemID == 15109 || abc.ItemID == 15110 || abc.ItemID == 15111 || abc.ItemID == 15112 || abc.ItemID == 15113 || abc.ItemID == 15114 || abc.ItemID == 15115 || abc.ItemID == 7086 )                    {
                    ison = true;
                    break;
                }
            }
            return ison;
        }

        public virtual void TurnOff(Mobile from, BaseAddon addon, int itemid)
        {
            AddonComponent component = null;

            if (addon == null || addon.Deleted)
                return;

        //Remove Displayed Items Here:
            for (int i = 0; i < addon.Components.Count; i++)
            {
                AddonComponent ac = addon.Components[i];

                if (ac != null && !ac.Deleted && ac.ItemID == itemid)
                {
                    component = ac;
                    break;
                }
            }

            if(component != null && !component.Deleted)
            {
                if (addon.Components.Contains(component))
                {
                    addon.Components.Remove(component);
                    component.Addon = null;
                    component.Delete();
                    from.SendMessage("You turn the TV off");
                }
            }
        }

        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 FlatScreenTvEastAddonDeed : BaseAddonDeed
    {
        public override BaseAddon Addon
        {
            get
            {
                return new FlatScreenTvEastAddon();
            }
        }

        [Constructable]
        public FlatScreenTvEastAddonDeed()
        {
            Name = "<BASEFONT COLOR=#01FD0E>4K Flat Screen Facing East";
        }

        public FlatScreenTvEastAddonDeed( 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 override void GetProperties( ObjectPropertyList list )
         {
             base.GetProperties( list );
            list.Add( "<BASEFONT COLOR=#01FD0E><BASEFONT COLOR=#75FBEB>Red Button to turn On/Off or<BR>Green Button change Channels" );
         }
    }
}

Any guidance or assistance would help me perfect this project

Many Thanks
 
Last edited:
Ok. I re-wrote this for a lil more complexity to show a better way to do it with channels and direct on specific buttons.

C#:
    public class FlatScreenTvEastAddon : BaseAddon
    {
        private bool m_TurnedOn;
        [CommandProperty(AccessLevel.GameMaster)]
        public bool TurnedOn { get { return m_TurnedOn; } set { m_TurnedOn = value; InvalidateProperties(); } }

        public int m_Channel;
        [CommandProperty(AccessLevel.GameMaster)]
        public int Channel { get { return m_Channel; } set { m_Channel = value; InvalidateProperties(); } }

        public override BaseAddonDeed Deed
        {
            get
            {
                return new FlatScreenTvEastAddonDeed();
            }
        }

        [Constructable]
        public FlatScreenTvEastAddon()
        {
            // TV Screen - Hued Black:
            AddComplexComponent((BaseAddon)this, 268, 0, 0, 2, 1, -1, "4k Flat Screen", 1);// 1
            AddComplexComponent((BaseAddon)this, 268, 0, 1, 2, 1, -1, "4k Flat Screen", 1);// 2

            // TV Frame One Side - Hued Grey:
            AddComplexComponent((BaseAddon)this, 64, 0, -1, 1, 2106, -1, "Frame", 1);// 3
            //AddComplexComponent( (BaseAddon) this, 64, 0, 1, 2, 2106, -1, "Frame", 1);// 4

            // TV Frames Top Bottom - Hued Grey:
            AddComplexComponent((BaseAddon)this, 81, 0, 0, 12, 2106, -1, "Frame", 1);// 5
            AddComplexComponent((BaseAddon)this, 81, 0, 1, 12, 2106, -1, "Frame", 1);// 6
            AddComplexComponent((BaseAddon)this, 81, 0, 1, 0, 2106, -1, "Frame", 1);// 7
            AddComplexComponent((BaseAddon)this, 81, 0, 0, 0, 2106, -1, "Frame", 1);// 8

            // TV Channel Button - Hued Green:
            AddTVChannelComponent((BaseAddon)this, 273, 0, 1, 7, 2702, -1, "Channel Button", 1);// 4

            // TV On/Off Button - Hued Red:
            AddTVPowerComponent((BaseAddon)this, 696, 0, 1, 2, 2642, -1, "On/Off Button", 1);// 4

        }

        public FlatScreenTvEastAddon(Serial serial) : base(serial)
        {
        }

        public void AddTVComponents(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource)
        {
            AddTVComponents(addon, item, xoffset, yoffset, zoffset, hue, lightsource, null, 1);
        }
        public void AddTVComponents(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
        {
            FlatScreenTVItem ac;
            ac = new FlatScreenTVItem();
            ac.ItemID = item;
            if (name != null && name.Length > 0)
                ac.Name = name;
            if (hue != 0)
                ac.Hue = hue;
            if (amount > 1)
            {
                ac.Stackable = true;
                ac.Amount = amount;
            }
            if (lightsource != -1)
                ac.Light = (LightType)lightsource;
            addon.AddComponent(ac, xoffset, yoffset, zoffset);
        }

        public void AddTVPowerComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource)
        {
            AddTVPowerComponent(addon, item, xoffset, yoffset, zoffset, hue, lightsource, null, 1);
        }
        public void AddTVPowerComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
        {
            FlatScreenTVPowerButton ac;
            ac = new FlatScreenTVPowerButton();
            ac.ItemID = item;
            if (name != null && name.Length > 0)
                ac.Name = name;
            if (hue != 0)
                ac.Hue = hue;
            if (amount > 1)
            {
                ac.Stackable = true;
                ac.Amount = amount;
            }
            if (lightsource != -1)
                ac.Light = (LightType)lightsource;
            addon.AddComponent(ac, xoffset, yoffset, zoffset);
        }

        public void AddTVChannelComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource)
        {
            AddTVChannelComponent(addon, item, xoffset, yoffset, zoffset, hue, lightsource, null, 1);
        }
        public void AddTVChannelComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
        {
            FlatScreenTVChannelButton ac;
            ac = new FlatScreenTVChannelButton();
            ac.ItemID = item;
            if (name != null && name.Length > 0)
                ac.Name = name;
            if (hue != 0)
                ac.Hue = hue;
            if (amount > 1)
            {
                ac.Stackable = true;
                ac.Amount = amount;
            }
            if (lightsource != -1)
                ac.Light = (LightType)lightsource;
            addon.AddComponent(ac, xoffset, yoffset, zoffset);
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource)
        {
            AddComplexComponent(addon, item, xoffset, yoffset, zoffset, hue, lightsource, null, 1);
        }

        private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
        {
            AddonComponent ac;
            ac = new AddonComponent(item);
            if (name != null && name.Length > 0)
                ac.Name = name;
            if (hue != 0)
                ac.Hue = hue;
            if (amount > 1)
            {
                ac.Stackable = true;
                ac.Amount = amount;
            }
            if (lightsource != -1)
                ac.Light = (LightType)lightsource;
            addon.AddComponent(ac, xoffset, yoffset, zoffset);
        }

        public virtual bool CanUseFromHouse { get { return true; } }
        public virtual void SetChannel(Mobile from, FlatScreenTvEastAddon addon)
        {
            if (addon == null || addon.Deleted)
                return;

            int firewrk = Utility.RandomList(1065, 1066, 1082, 1089, 1099, 1071, 1073, 1076, 1102);

            int firewrks = Utility.RandomList(1066, 1082, 1089, 1099, 1102, 1088, 1088);

            switch (addon.Channel)
            {
                default:
                case 1:
                    switch (Utility.Random(5))
                    {
                        //Head and Galaxy:
                        case 0:
                            AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 0, -1, "4K Flat Screen", 1);
                            AddTVComponents((BaseAddon)this, 10984, 1, 1, 11, 1102, -1, "4K Flat Screen", 1); break;
                        case 1:
                            AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 33, -1, "4K Flat Screen", 1);
                            AddTVComponents((BaseAddon)this, 10984, 1, 1, 11, 1089, -1, "4K Flat Screen", 1); break;
                        case 2:
                            AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 59, -1, "4K Flat Screen", 1);
                            AddTVComponents((BaseAddon)this, 10984, 1, 1, 11, 1089, -1, "4K Flat Screen", 1); break;
                        case 3:
                            AddTVComponents((BaseAddon)this, 7916, 1, 0, 9, 59, -1, "4K Flat Screen", 1);
                            AddTVComponents((BaseAddon)this, 10984, 1, 1, 12, 2951, -1, "4K Flat Screen", 1); break;
                        case 4:
                            AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 91, -1, "4K Flat Screen", 1);
                            AddTVComponents((BaseAddon)this, 10984, 1, 1, 12, 1099, -1, "4K Flat Screen", 1); break;
                    }
                    break;
                case 2:
                    switch (Utility.Random(16))
                    {
                        //Head and Energy Wave:
                        case 0: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 0, -1, "4K Flat Screen", 1); break;
                        case 1: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2946, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2946, -1, "4K Flat Screen", 1); break;
                        case 2: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2947, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2947, -1, "4K Flat Screen", 1); break;
                        case 3: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2950, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2950, -1, "4K Flat Screen", 1); break;
                        case 4: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2981, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2981, -1, "4K Flat Screen", 1); break;
                        case 5: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2991, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2991, -1, "4K Flat Screen", 1); break;
                        case 6: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2995, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2995, -1, "4K Flat Screen", 1); break;
                        case 7: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2831, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2831, -1, "4K Flat Screen", 1); break;
                        case 8: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2848, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2848, -1, "4K Flat Screen", 1); break;
                        case 9: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2865, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2865, -1, "4K Flat Screen", 1); break;
                        case 10: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2876, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2876, -1, "4K Flat Screen", 1); break;
                        case 11: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2879, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 91, -1, "4K Flat Screen", 1); break;
                        case 12: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2817, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2817, -1, "4K Flat Screen", 1); break;
                        case 13: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2802, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2802, -1, "4K Flat Screen", 1); break;
                        case 14: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2792, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2792, -1, "4K Flat Screen", 1); break;
                        case 15: AddTVComponents((BaseAddon)this, 14360, 1, 1, 13, 2779, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7916, 1, 0, 8, 2779, -1, "4K Flat Screen", 1); break;
                    }
                    break;
                case 3:
                    switch (Utility.Random(9))
                    {
                        //Runes and Gems:
                        case 0: AddTVComponents((BaseAddon)this, 3676, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3855, 1, 1, 12, 0, -1, "4K Flat Screen", 1); break;
                        case 1: AddTVComponents((BaseAddon)this, 3679, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3888, 1, 1, 17, 0, -1, "4K Flat Screen", 1); break;
                        case 2: AddTVComponents((BaseAddon)this, 3682, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3888, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3869, 1, 1, 17, 0, -1, "4K Flat Screen", 1); break;
                        case 3: AddTVComponents((BaseAddon)this, 3888, 1, 1, 17, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3685, 1, 1, 13, 0, -1, "4K Flat Screen", 1); break;
                        case 4: AddTVComponents((BaseAddon)this, 3688, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3884, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 5: AddTVComponents((BaseAddon)this, 15442, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 15449, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 15448, 1, 1, 10, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3869, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 7, 0, -1, "4K Flat Screen", 1); break;
                        case 6: AddTVComponents((BaseAddon)this, 15443, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 15446, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3884, 1, 1, 17, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 5, 0, -1, "4K Flat Screen", 1); break;
                        case 7: AddTVComponents((BaseAddon)this, 15445, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 15444, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3888, 1, 1, 17, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 4, 0, -1, "4K Flat Screen", 1); break;
                        case 8: AddTVComponents((BaseAddon)this, 15447, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 15449, 1, 1, 10, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3888, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3870, 1, 0, 9, 0, -1, "4K Flat Screen", 1); break;
                    }
                    break;
                case 4:
                    switch (Utility.Random(8))
                    {
                        //Fireworks:
                        case 0: AddTVComponents((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 10980, 1, 1, 11, firewrk, -1, "4K Flat Screen", 1); break;
                        case 1: AddTVComponents((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 10980, 1, 1, 11, firewrk, -1, "4K Flat Screen", 1); break;
                        case 2: AddTVComponents((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 13401, 1, 1, 11, firewrks, -1, "4K Flat Screen", 1); break;
                        case 3: AddTVComponents((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 13401, 1, 1, 11, firewrks, -1, "4K Flat Screen", 1); break;
                        case 4: AddTVComponents((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 14133, 1, 1, 11, firewrks, -1, "4K Flat Screen", 1); break;
                        case 5: AddTVComponents((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 14133, 1, 1, 11, firewrks, -1, "4K Flat Screen", 1); break;
                        case 6: AddTVComponents((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7878, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7193, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                        case 7: AddTVComponents((BaseAddon)this, 14201, 1, 1, 10, 2104, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7878, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7193, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                    }
                    break;
                case 5:
                    switch (Utility.Random(13))
                    {
                        //Flowers:
                        case 0: AddTVComponents((BaseAddon)this, 4893, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 1161, -1, "4K Flat Screen", 1); break;
                        case 1: AddTVComponents((BaseAddon)this, 4942, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 2: AddTVComponents((BaseAddon)this, 4986, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 3: AddTVComponents((BaseAddon)this, 4987, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 4: AddTVComponents((BaseAddon)this, 4988, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 5: AddTVComponents((BaseAddon)this, 4975, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 6: AddTVComponents((BaseAddon)this, 6377, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 7: AddTVComponents((BaseAddon)this, 6378, 1, 1, 12, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 8: AddTVComponents((BaseAddon)this, 6809, 1, 1, 9, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 9: AddTVComponents((BaseAddon)this, 4993, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 10: AddTVComponents((BaseAddon)this, 5003, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 11: AddTVComponents((BaseAddon)this, 5001, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                        case 12: AddTVComponents((BaseAddon)this, 5002, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3877, 1, 1, 16, 0, -1, "4K Flat Screen", 1); break;
                    }
                    break;
                case 6:
                    switch (Utility.Random(14))
                    {
                        //Fish:
                        case 0: AddTVComponents((BaseAddon)this, 15101, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 1: AddTVComponents((BaseAddon)this, 15102, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 2: AddTVComponents((BaseAddon)this, 15103, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 3: AddTVComponents((BaseAddon)this, 15105, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 4: AddTVComponents((BaseAddon)this, 15104, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 5: AddTVComponents((BaseAddon)this, 15107, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 6: AddTVComponents((BaseAddon)this, 15113, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 7: AddTVComponents((BaseAddon)this, 15112, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 8: AddTVComponents((BaseAddon)this, 15108, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 9: AddTVComponents((BaseAddon)this, 15109, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 10: AddTVComponents((BaseAddon)this, 15110, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 11: AddTVComponents((BaseAddon)this, 15114, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 12: AddTVComponents((BaseAddon)this, 15111, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                        case 13: AddTVComponents((BaseAddon)this, 15115, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7086, 1, 0, 12, 1161, -1, "4K Flat Screen", 1); break;
                    }
                    break;
                case 7:
                    switch (Utility.Random(10))
                    {
                        //Stars and Moon:
                        case 0: AddTVComponents((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3887, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 7, 0, -1, "4K Flat Screen", 1); break;
                        case 1: AddTVComponents((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 8, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 6, 0, -1, "4K Flat Screen", 1); break;
                        case 2: AddTVComponents((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3873, 1, 1, 10, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 4, 0, -1, "4K Flat Screen", 1); break;
                        case 3: AddTVComponents((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3862, 1, 1, 13, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 4, 0, -1, "4K Flat Screen", 1); break;
                        case 4: AddTVComponents((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3869, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 4, 0, -1, "4K Flat Screen", 1); break;
                        case 5: AddTVComponents((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3884, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3870, 1, 0, 10, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 4, 0, -1, "4K Flat Screen", 1); break;
                        case 6: AddTVComponents((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3888, 1, 1, 14, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3870, 1, 0, 7, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                        case 7: AddTVComponents((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7878, 1, 1, 13, 1161, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3870, 1, 0, 7, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                        case 8: AddTVComponents((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7878, 1, 1, 13, 1161, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3869, 1, 1, 16, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                        case 9: AddTVComponents((BaseAddon)this, 8903, 1, 1, 15, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 7878, 1, 1, 13, 1161, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3873, 1, 1, 11, 0, -1, "4K Flat Screen", 1); AddTVComponents((BaseAddon)this, 3885, 1, 0, 10, 0, -1, "4K Flat Screen", 1); break;
                    }
                    break;
            }
        }
        public virtual void TurnOff(Mobile from, BaseAddon addon)
        {
            AddonComponent component = null;

            if (addon == null || addon.Deleted)
                return;

            //Remove Displayed Items Here:
            for (int i = addon.Components.Count - 1; i > -1 ; i--)
            {
                AddonComponent ac = addon.Components[i];

                if (ac != null && !ac.Deleted && ac is FlatScreenTVItem)
                {
                    component = ac;
                    if (addon.Components.Contains(component))
                    {
                        addon.Components.Remove(component);
                        component.Addon = null;
                        component.Delete();
                    }
                }
            }



        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write(1); // Version

            //version 1
            writer.Write(m_Channel);
            writer.Write(m_TurnedOn);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            switch (version)
            {
                case 1:
                    {
                        m_Channel = reader.ReadInt();
                        m_TurnedOn = reader.ReadBool();
                        goto case 0;
                    }
                case 0:
                    {
                        break;
                    }
            }
        }

    }
    public class FlatScreenTvEastAddonDeed : BaseAddonDeed
    {
        public override BaseAddon Addon
        {
            get
            {
                return new FlatScreenTvEastAddon();
            }
        }

        [Constructable]
        public FlatScreenTvEastAddonDeed()
        {
            Name = "<BASEFONT COLOR=#01FD0E>4K Flat Screen Facing East";
        }

        public FlatScreenTvEastAddonDeed(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 override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);
            list.Add("<BASEFONT COLOR=#01FD0E><BASEFONT COLOR=#75FBEB>Red Button to turn On/Off or<BR>Green Button change Channels");
        }
    }
    public class FlatScreenTVItem : AddonComponent
    {
        [Constructable]
        public FlatScreenTVItem() : base(7916)
        {
            Weight = 1.0;
        }

        public FlatScreenTVItem(Serial serial) : base(serial)
        {
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
        }

    }
    public class FlatScreenTVPowerButton : AddonComponent
    {
        [Constructable]
        public FlatScreenTVPowerButton() : base(696)
        {
            Weight = 1.0;
        }

        public FlatScreenTVPowerButton(Serial serial) : base(serial)
        {
        }

        public override void OnDoubleClick(Mobile from)
        {
            base.OnDoubleClick(from);


            if (Addon == null || Addon.Deleted)
                return;

            BaseHouse house = BaseHouse.FindHouseAt(this);

            if (house == null || house.Deleted)
                return;

            if (house != null && !house.IsOwner(from))
            {
                from.SendMessage("You do not own this.");
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("You are too far away.");
                return;
            }

            if (((FlatScreenTvEastAddon)Addon).TurnedOn)
            {
                ((FlatScreenTvEastAddon)Addon).TurnOff(from, (FlatScreenTvEastAddon)Addon);
                from.SendMessage("You turn the TV off.");
                ((FlatScreenTvEastAddon)Addon).TurnedOn = false;
            }
            else
            {
                if (((FlatScreenTvEastAddon)Addon).Channel <= 0)
                    ((FlatScreenTvEastAddon)Addon).Channel = 1;
                from.SendMessage("You turn the TV on.");
                ((FlatScreenTvEastAddon)Addon).TurnedOn = true;
                ((FlatScreenTvEastAddon)Addon).SetChannel(from, (FlatScreenTvEastAddon)Addon);

            }

        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
        }

    }
    public class FlatScreenTVChannelButton : AddonComponent
    {
        [Constructable]
        public FlatScreenTVChannelButton() : base(273)
        {
            Weight = 1.0;
        }

        public FlatScreenTVChannelButton(Serial serial) : base(serial)
        {
        }
        public override void OnDoubleClick(Mobile from)
        {
            base.OnDoubleClick(from);


            if (Addon == null || Addon.Deleted)
                return;

            BaseHouse house = BaseHouse.FindHouseAt(this);

            if (house == null || house.Deleted)
                return;

            if (house != null && !house.IsOwner(from))
            {
                from.SendMessage("You do not own this.");
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("You are too far away.");
                return;
            }

            if (((FlatScreenTvEastAddon)Addon).TurnedOn)
            {
                ((FlatScreenTvEastAddon)Addon).TurnOff(from, (FlatScreenTvEastAddon)Addon);

                ((FlatScreenTvEastAddon)Addon).Channel++;

                if (((FlatScreenTvEastAddon)Addon).Channel >= 7)
                    ((FlatScreenTvEastAddon)Addon).Channel = 1;

                ((FlatScreenTvEastAddon)Addon).SetChannel(from, (FlatScreenTvEastAddon)Addon);
                from.SendMessage("You change the channel.");
            }


        }
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
        }

    }



This should do what you want it to do and you can see how I used new components to let you set them directly on those components double-clicks. Should work well at least it is one way to do it.
 
Amazed again! This works perfectly. I only needed to adjust a few Z axis values on some of gemstones so they did not pop through the ceiling when the TV was raised on the wall.

I am deeply in your debt . . . So now, on our shard the 'Dramoor Flat Screen' is born!

Thank you friend, not only for your scripting skills but for your very fast replies and willingness to help.

*bows*
 
Last edited:
You can do stuff in the OnComponentUsed, and then check the component being used. Then you would add the items to the addon on used and either set a flag or use the items added if detected or double-clicked, to turn it back off by having it remove the items from the addon.
Excellent idea! Using OnComponentUsed enables changes in behavior. The technique of adding objects on use and keeping a flag or detection for removal is a clever and successful look at of dealing with in-game traits.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back