ServUO Version
Publish 57
Ultima Expansion
Endless Journey
I am looking to make a custom bridge out of a carpet script I have where the carpets are sizable. I want to take 3 items and stack them on one another I am not 100% sure on how to do this and I am getting an error when I try to compile my script.

This is the script line I am having an issue with:

case BridgePiece.Left: return {{0x4319},{0x23BA},{0x2AO}};
And this is the Error I am getting when I try t start me server:
Testing/BridgeTest.cs:
CS1525: Line 44: Invalid expression term '{'
CS1002: Line 44: ; expected
CS1002: Line 44: ; expected
CS1513: Line 44: } expected
CS1002: Line 44: ; expected
CS1513: Line 44: } expected
CS1002: Line 44: ; expected
CS1002: Line 44: ; expected
Scripts: One or more scripts failed to compile or no script files were found.


Can anyone point me in the right direction with this please!!!!
 
You can always just return 1 object, you cant return multiple objects at once.

A way around that is returning 1 array, that can hold multiple objects, since an array is 1 object itself.
Same with a tuple. But thats another topic :)

What you would want is to return the array. But I dont think your script for placing would work with an array.
 
thank you I will keep looking more and try and figure out how to do what I want to do thank you for answering me :)
 
Just an example : not tested, ai generated it to give you a base to start with, and to show the power of using ai to help with ServUO related questions!

Chat GPT

Prompt used to generate code!
Code:
Acting as an expert on ServUO solve and give code examples to the following : "provide the best example for making a bridge made from carpet item art that a player can place using a deed, like a current addon does, the bridge should be three tiles long, use the players location as the starting point for bridge, make sure to have it where you double tap the bridge, it goes back to deed form!"

Code generated!
Code:
using System;
using Server;
using Server.Targeting;
using Server.Items;

namespace CustomBridge
{
    public class CustomBridgeDeed : Item
    {
        [Constructable]
        public CustomBridgeDeed() : base(0x14F0)
        {
            Name = "Custom Bridge Deed";
            Hue = 1153;
            Weight = 1.0;
        }

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

        public override void OnDoubleClick(Mobile from)
        {
            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
            }
            else
            {
                from.SendMessage("Where do you want to start the bridge?");
                from.Target = new CustomBridgeTarget(this);
            }
        }

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

        private class CustomBridgeTarget : Target
        {
            private CustomBridgeDeed m_Deed;

            public CustomBridgeTarget(CustomBridgeDeed deed) : base(3, false, TargetFlags.None)
            {
                m_Deed = deed;
            }

            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is IPoint3D)
                {
                    Point3D p = new Point3D((IPoint3D)targeted);

                    if (!Map.CanFit(p.X, p.Y, p.Z, 3, false, false))
                    {
                        from.SendMessage("You cannot build a bridge here.");
                    }
                    else
                    {
                        from.SendMessage("Which direction do you want the bridge to face?");
                        from.Target = new CustomBridgeDirectionTarget(m_Deed, p);
                    }
                }
                else
                {
                    from.SendMessage("Invalid target.");
                }
            }
        }

        private class CustomBridgeDirectionTarget : Target
        {
            private CustomBridgeDeed m_Deed;
            private Point3D m_Start;

            public CustomBridgeDirectionTarget(CustomBridgeDeed deed, Point3D start) : base(-1, true, TargetFlags.None)
            {
                m_Deed = deed;
                m_Start = start;
            }

            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is StaticTarget)
                {
                    int itemID = ((StaticTarget)targeted).ItemID;

                    if (itemID == 0x0C1D || itemID == 0x0C1E || itemID == 0x0C1F)
                    {
                        Direction dir = ((StaticTarget)targeted).Facing;
                        int[][] bridge = new int[][] {
                            new int[] { 0x23BA, 0x4319, 0x23BA },
                            new int[] { 0x23BA, 0x23BA, 0x23BA },
                            new int[] { 0x2A0, 0x2A0, 0x2A0 }
                        };
                        Point3D[] tiles = new Point3D[3];
                        tiles[0] = m_Start;

                        if (dir == Direction

                    {
                        tiles[1] = new Point3D(m_Start.X - 1, m_Start.Y, m_Start.Z);
                        tiles[2] = new Point3D(m_Start.X - 2, m_Start.Y, m_Start.Z);
                    }
                    else if (dir == Direction.South)
                    {
                        tiles[1] = new Point3D(m_Start.X, m_Start.Y + 1, m_Start.Z);
                        tiles[2] = new Point3D(m_Start.X, m_Start.Y + 2, m_Start.Z);
                    }
                    else if (dir == Direction.East)
                    {
                        tiles[1] = new Point3D(m_Start.X + 1, m_Start.Y, m_Start.Z);
                        tiles[2] = new Point3D(m_Start.X + 2, m_Start.Y, m_Start.Z);
                    }
                    else if (dir == Direction.West)
                    {
                        tiles[1] = new Point3D(m_Start.X - 1, m_Start.Y, m_Start.Z);
                        tiles[2] = new Point3D(m_Start.X - 2, m_Start.Y, m_Start.Z);
                    }
                    else if (dir == Direction.North)
                    {
                        tiles[1] = new Point3D(m_Start.X, m_Start.Y - 1, m_Start.Z);
                        tiles[2] = new Point3D(m_Start.X, m_Start.Y - 2, m_Start.Z);
                    }

                    CustomBridge bridgeItem = new CustomBridge(bridge, from.Map, tiles[0], tiles[1], tiles[2], dir);

                    if (from.PlaceInBackpack(bridgeItem))
                    {
                        m_Deed.Delete();
                        from.SendMessage("You have created a custom bridge!");
                    }
                    else
                    {
                        from.SendMessage("You do not have enough room in your backpack for the bridge.");
                        bridgeItem.Delete();
                    }
                }
                else
                {
                    from.SendMessage("You must target a directional carpet to determine the bridge direction.");
                }
            }
            else
            {
                from.SendMessage("Invalid target.");
            }
        }
    }
}

public class CustomBridge : BaseAddon
{
    private int[][] m_Bridge;
    private Point3D m_StartTile;
    private Point3D m_MiddleTile;
    private Point3D m_EndTile;
    private Direction m_Direction;

    [Constructable]
    public CustomBridge(int[][] bridge, Map map, Point3D startTile, Point3D middleTile, Point3D endTile, Direction dir) : base()
    {
        m_Bridge = bridge;
        m_StartTile = startTile;
        m_MiddleTile = middleTile;
        m_EndTile = endTile;
        m_Direction = dir;

        for (int i = 0; i < bridge.Length; i++)
        {
            for (int j = 0; j < bridge[i].Length; j++)
            {
                AddComponent(new CustomBridgeComponent(bridge[i][j]), i - 1, j - 1, 0);
            }
        }

        Movable = false;
        Map = map;
    }

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

    public override void OnDoubleClick(Mobile from)
    {
        if (from.AccessLevel >= AccessLevel.GameMaster)
        {
            from.SendGump(new PropertiesGump(from, this));
        }
        else
        {
            from.SendMessage("Double-click the bridge to turn it back into a deed.");
        }
    }

    public override void OnDoubleClickDead(Mobile from)
    {
        from.SendLocalizedMessage(1048146

    }

    public override void OnComponentUsed(AddonComponent c, Mobile from)
    {
        if (from.AccessLevel >= AccessLevel.GameMaster)
        {
            from.SendGump(new PropertiesGump(from, c));
        }
    }

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

        writer.Write((int)0);

        writer.Write(m_Bridge.Length);
        for (int i = 0; i < m_Bridge.Length; i++)
        {
            writer.Write(m_Bridge[i].Length);
            for (int j = 0; j < m_Bridge[i].Length; j++)
            {
                writer.Write(m_Bridge[i][j]);
            }
        }

        writer.Write(m_StartTile);
        writer.Write(m_MiddleTile);
        writer.Write(m_EndTile);
        writer.Write((int)m_Direction);
    }

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

        int version = reader.ReadInt();

        int length = reader.ReadInt();
        m_Bridge = new int[length][];
        for (int i = 0; i < length; i++)
        {
            int innerLength = reader.ReadInt();
            m_Bridge[i] = new int[innerLength];
            for (int j = 0; j < innerLength; j++)
            {
                m_Bridge[i][j] = reader.ReadInt();
            }
        }

        m_StartTile = reader.ReadPoint3D();
        m_MiddleTile = reader.ReadPoint3D();
        m_EndTile = reader.ReadPoint3D();
        m_Direction = (Direction)reader.ReadInt();
    }
}

public class CustomBridgeComponent : AddonComponent
{
    private int m_ItemID;

    public override int LabelNumber { get { return 1041413; } } // a bridge section

    [Constructable]
    public CustomBridgeComponent(int itemID) : base()
    {
        m_ItemID = itemID;

        Movable = false;
    }

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

    public override void OnDoubleClick(Mobile from)
    {
        if (from.AccessLevel >= AccessLevel.GameMaster)
        {
            from.SendGump(new PropertiesGump(from, this));
        }
        else
        {
            from.SendMessage("Double-click the bridge to turn it back into a deed.");
        }
    }

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

        writer.Write((int)0);

        writer.Write(m_ItemID);
    }

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

        int version = reader.ReadInt();

        m_ItemID = reader.ReadInt();
    }

    public override void OnPropertiesChanged()
    {
        ItemID = m_ItemID;
    }
}
}
 
Back