ServUO Version
Publish Unknown
Ultima Expansion
The Second Age
I have made changes to get this script to compile on runuo 1.0. when I try to add the Item the server crashes with this error.

RunUO Version 1.0.0, Build 36918
Operating System: Microsoft Windows NT 6.2.9200.0
.NET Framework: 1.1.4322.573
Time: 2/13/2023 9:41:35 AM
Mobiles: 6526
Items: 145592
Clients:
- Count: 1
+ 127.0.0.1: (account = bang) (mobile = 0x92F 'bang')

Exception:
System.StackOverflowException: Exception of type System.StackOverflowException was thrown.

this is the updated script.
C#:
using Server;
using System;
using Server.Network;
using Server.Engines.Plants;
using Server.Gumps;
using Server.Multis;
using Server.Items;

namespace Server.Items
{
    public class Tomato : Food
    {
        [Constructable]
        public Tomato()
            : this(1)
        {
        }

        [Constructable]
        public Tomato(int amount)
            : base(amount, 0x9D0)
        {
            Name = "Tomato";
            Weight = 1.0;
            FillFactor = 1;
        }

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

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

            writer.Write((int)0);
        }

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

            int version = reader.ReadInt();
        }
    }

    public class PottedTomatoPlant : BaseAddon, ISecurable
    {
        public static readonly TimeSpan CheckDelay = TimeSpan.FromHours(23.0);

        private static int[,] m_AddOnSimpleComponents = new int[,]
        {
              {2323, 0, 0, 2}, {4551, 0, 0, 0}, {3563, 0, 0, 2}   
        };


        private PlantStatus m_PlantStatus;
        private Timer m_Timer;

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

        [CommandProperty(AccessLevel.GameMaster)]
        public PlantStatus PlantStatus
        {
            get { return m_PlantStatus; }
            set
            {
                switch (value)
                {
                    case PlantStatus.Stage1: { ItemID = 0xDEB; break; }
                    case PlantStatus.Stage2: { ItemID = 0xDEC; break; }
                    case PlantStatus.Stage3: { ItemID = 0xDED; break; }
                    case PlantStatus.Stage4: { ItemID = 0xDEE; break; }
                }

                m_PlantStatus = value;
//               Visible = True;
            }
        }

        [CommandProperty(AccessLevel.GameMaster)]
        public DateTime NextGrowth
         {
            get{ return NextGrowth; }
            set{ NextGrowth = value; }
        }       

        [CommandProperty(AccessLevel.GameMaster)]
       public SecureLevel Level
         {
            get{ return Level; }
            set{ Level = value; }
        }     

        [Constructable]
        public PottedTomatoPlant()
          
        {
            Name = "Potted Tomato Plant";
            Weight = 5.0;
            PlantStatus = PlantStatus.Stage1;
            NextGrowth = DateTime.UtcNow + CheckDelay;
            StartTimer();

            for (int i = 0; i < m_AddOnSimpleComponents.Length / 4; i++)
                AddComponent(new AddonComponent(m_AddOnSimpleComponents[i, 0]), m_AddOnSimpleComponents[i, 1], m_AddOnSimpleComponents[i, 2], m_AddOnSimpleComponents[i, 3]);
            
        }

        public bool CheckAccessible(Mobile from, Item item)
        {
            if (from.AccessLevel >= AccessLevel.GameMaster)
                return true;

            BaseHouse house = BaseHouse.FindHouseAt(item);

            if (house == null)
                return false;

            switch (Level)
            {
                case SecureLevel.Owner: return house.IsOwner(from);
               case SecureLevel.CoOwners: return house.IsCoOwner(from);
               case SecureLevel.Friends: return house.IsFriend(from);
                case SecureLevel.Anyone: return true;
//                case SecureLevel.Guild: return house.IsGuildMember(from);
            }

            return false;
        }

        public void OnTick()
        {
            if (PlantStatus < PlantStatus.Stage4)
            {
                if (NextGrowth < DateTime.UtcNow)
                {
                    PlantStatus++;
                    NextGrowth = DateTime.UtcNow + CheckDelay;
                }
            }
            else
            {
                StopTimer();
            }
        }

        public void StopTimer()
        {
            if (m_Timer != null)
                m_Timer.Stop();

            m_Timer = null;
        }

        public void StartTimer()
        {
            if (m_Timer != null)
                return;

            m_Timer = Timer.DelayCall(TimeSpan.FromHours(1.0), TimeSpan.FromHours(1.0), new TimerCallback(OnTick));
        }

        public override void OnDoubleClick(Mobile from)
        {
            if (!from.InRange(this, 4))
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1019045);
                return;
            }

            if (CheckAccessible(from, this))
           {
               if (PlantStatus == PlantStatus.Stage4)
                {
                    LabelTo(from, 501016); // *You pick some fruit and put it in your backpack*
                    PlantStatus--;
                    from.AddToBackpack(new Tomato(5));
                    NextGrowth = DateTime.UtcNow + CheckDelay;
                    StartTimer();
                }
                else
                {
                    from.SendLocalizedMessage(1155695); // The plant is not ready to be picked from.
                }
            }
        }

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

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

            writer.Write((int)0);
            writer.Write((int)PlantStatus);
            writer.Write((int)Level);
            writer.Write((DateTime)NextGrowth);
        }

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

            int version = reader.ReadInt();
            PlantStatus = (PlantStatus)reader.ReadInt();
            Level = (SecureLevel)reader.ReadInt();
            NextGrowth = reader.ReadDateTime();

            if (PlantStatus < PlantStatus.Stage4)
                StartTimer();
        }       
    }
    public class PottedTomatoPlantDeed : BaseAddonDeed
    {
        public override BaseAddon Addon
        {
            get
            {
                return new PottedTomatoPlant();
            }
        }

        [Constructable]
        public PottedTomatoPlantDeed()
        {
            Name = "Potted Tomato Plant";
        }

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

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

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();
        }
    }
}
 
Your culprit is:

C#:
        [CommandProperty(AccessLevel.GameMaster)]
        public DateTime NextGrowth
         {
            get{ return NextGrowth; }
            set{ NextGrowth = value; }
        }       

        [CommandProperty(AccessLevel.GameMaster)]
       public SecureLevel Level
         {
            get{ return Level; }
            set{ Level = value; }
        }

you try to return the property which in return tries to return the propertiy which in return tries to ......

also
you try to set the property where you try to set the property where you try to ...

and thats whats causing your stackoverflow
 
PottedTomatoPlant : BaseAddon
and the
public PottedTomatoPlant
I changed this here
C#:
        [CommandProperty(AccessLevel.GameMaster)]
        public DateTime NextGrowth {get; set;}
//         {
//            get{ return NextGrowth; }
//            set{ NextGrowth = value; }
//        }       

        [CommandProperty(AccessLevel.GameMaster)]
       public SecureLevel Level {get; set;}
//        {
//            get{ return Level; }
//            set{ Level = value; }
//        }

get these errors

- Error: Scripts\custom\AAAAA\tomatoPlant.cs: CS0501: (line 88, column 37) 'Server.Items.PottedTomatoPlant.NextGrowth.get' must declare a body because it is not marked abstract or extern
- Error: Scripts\custom\AAAAA\tomatoPlant.cs: CS0501: (line 88, column 42) 'Server.Items.PottedTomatoPlant.NextGrowth.set' must declare a body because it is not marked abstract or extern
- Error: Scripts\custom\AAAAA\tomatoPlant.cs: CS0501: (line 95, column 34) 'Server.Items.PottedTomatoPlant.Level.get' must declare a body because it is not marked abstract or extern
- Error: Scripts\custom\AAAAA\tomatoPlant.cs: CS0501: (line 95, column 39) 'Server.Items.PottedTomatoPlant.Level.set' must declare a body because it is not marked abstract or extern
 
Last edited:
since you are using RunUO 1.0, I assume your Net version for that is quite old.
Therefor

C#:
        private DateTime m_nextGrowth;
        [CommandProperty(AccessLevel.GameMaster)]
        public DateTime NextGrowth {get; set;}
         {
            get{ return m_nextGrowth; }
            set{ m_nextGrowth = value; }
        }       

        private SecureLevel m_level;
        [CommandProperty(AccessLevel.GameMaster)]
        public SecureLevel Level {get; set;}
        {
            get{ return m_level; }
            set{ m_level = value; }
        }
 
C#:
            private DateTime m_nextGrowth;

            [CommandProperty(AccessLevel.GameMaster)]
            public DateTime NextGrowth
             {
                get{ return m_nextGrowth; }
                set{ m_nextGrowth = value; }
            }   

            private SecureLevel m_level;

            [CommandProperty(AccessLevel.GameMaster)]
            public SecureLevel Level
            {
                get{ return m_level; }
                set{ m_level = value; }
            }
@PyrO had the correct answer, I'm just removing the {get; set;}
 
It works thank you for the help!
I have one last thing.
Im trying to get the plant to go back to stage1 after picking it.
It goes to stage3 rather then starting from stage1. Any Ideas?
 
Back