Having a hard time understanding why this will not work (Dyetubs)

Anomaly

Well-Known Member
Mar 9, 2014
50
5
30
Augusta, Georgia
Shard Name
Elanmire
fun facts about what i am doing:
- No changes have been made to DyeTub.cs
- This was originally "Blaze DyeTub", attempting to modify it to fit my need.

BossDyeTub.cs:
using System;

namespace Server.Items
{
    public class BossDyeTub : DyeTub
    {
        [Constructable]
        public BossDyeTub(int i)
        {
            this.Redyable = false;
            //this.Hue = this.DyedHue = 0x300;
            switch (i)
            {
                case 1:
                    {
                        //this.Hue = this.DyedHue = 0x300; //tried no worky worky
                        this.Hue = 0x300; //<--this works, item hue works w/ above too.
                        this.DyedHue = 768; //<--this is not being set ingame [props.
                        break;
                    }
                case 2:
                    {
                        //this.Hue = this.DyedHue = 0x300; //tried no worky worky
                        this.Hue = 0x489; //<--this works, item hue works w/ above too.
                        this.DyedHue = 1161; //<--this is not being set ingame [props.
                        break;
                    }       
            }
        }

        public BossDyeTub(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();
        }
    }
}
So, i can add the game in fine. And the item is created w/ its assigned hue based on the int i pass in on [add
EG: [add bossdyetub1 or [add bossdyetub 2

However after reviewing [props of both, and with both the commented line within the switch and the non-commented lines the Dyed Hue is not being set. Another thing to note w/ this.DyedHue is i also tried 0x489 for example instead of 1161..


TLDR: item creates w/ assigned hue, however won't dye things and has no dyedhue assigned though it is defined.
Post automatically merged:

leaving the post here in case anyone comes after me... i wasn't giving up and waiting... got to looking at DyedHue in DyeTub.cs...

DyeTub.cs:
        [CommandProperty(AccessLevel.GameMaster)]
        public int DyedHue
        {
            get { return m_DyedHue; }
            set
            {
                if (m_Redyable)
                {
                    m_DyedHue = value;
                    Hue = value;
                }
            }
        }
Applying this change to my code worked:


BossDyeTub.cs:
        public BossDyeTub(int i)
        {
            //this.Redyable = false;
            //this.Hue = this.DyedHue = 0x300;
            switch (i)
            {
                case 1:
                    {
                        //this.Hue = this.DyedHue = 0x300; //tried no worky worky
                        this.Hue = 0x300; //<--this works, item hue works w/ above too.
                        this.DyedHue = 768; //<--this is not being set ingame [props.
                        break;
                    }
                case 2:
                    {
                        //this.Hue = this.DyedHue = 0x300; //tried no worky worky
                        this.Hue = 0x489; //<--this works, item hue works w/ above too.
                        this.DyedHue = 1161; //<--this is not being set ingame [props.
                        break;
                    }       
            }
        }
Only downside is now this item will be redyeable.. but it works now.
 
Last edited:

Grimoric

Well-Known Member
Mar 21, 2015
189
48
44
I havnt tested anything but what happens if you add this.Redyable = false after the switch?

-Grim
 

Espcevan

Active Member
Apr 21, 2015
27
8
31
All I did was move the Redyable part into the switch of each item itself.


C#:
        [Constructable]
        public BossDyeTub(int i)
        {
            //this.Redyable = false;  //Remove this before the 'switch (i)'
            switch (i)
            {
                case 1:
                    {
                        this.Hue = 0x300;
                        this.DyedHue = 0x300;
                        this.Redyable = false;//<--add this into the switch case itself
                        break;
                    }
                case 2:
                    {
                        this.Hue = 0x489;
                        this.DyedHue = 0x489;
                        this.Redyable = false;//<--add this into the switch case itself
                        break;
                    }
            }
        }


Tested and works like it should.

You could also do something like...
C#:
                case 1:
                    {
                        this.Hue = 0x300;
                        this.DyedHue = this.Hue;
                        this.Redyable = false;//<--add this into the switch case itself
                        break;
                    }