Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 08-24-2008, 10:33 PM   #26 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by Pantoute View Post
Ho sorry, I tought that you had written "Ha! De rien" But with a lot of mistakes :P

There's a lot of languages that has words that look-alike.

By the way, what does ahh der ian! mean?
I meant to write "you're welcome" ... de rien.

ahh... just an American-ism for "oh," or "hmm."
Tassyon T is offline   Reply With Quote
Old 08-24-2008, 10:39 PM   #27 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by Pantoute View Post

hmm What if I wanted the new item to keep the same hue as the first?




Declare another private variable in your gump...

Code:
            private int RetainedHue;


Add the hue as another argument when you call your gump...
Code:
           public ChristianMenuGump(object obj, Item OldFlippableItem, Item NewFlippedItem, int oldhue): base(0, 0)
Assign the argument value to your private int.

Code:
RetainedHue = oldhue;
and assign the hue to your new item OnResponse...

Code:
       public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                      m_Obj.SendMessage("Vous tournez le lit");
                      Item item = NewItem;
                      item.Hue = RetainedHue;
                      item.MoveToWorld(OldItem.Location, OldItem.Map);  

                      OldItem.Delete();
                //It is here that I need to "send" a bool or change or I don't know


                //C'est ici que j'ai besoin "d'envoyer" un bool ou changer ou je sais pas
                
            }

In your item script...

pass this.Hue as an argument.
Tassyon T is offline   Reply With Quote
Old 08-25-2008, 09:18 AM   #28 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

Thank you, it worked without problem. I'll also be able to use that for other properties.


EDIT: But now I have to get the world location.here's what I did and it doesn't want to work.

Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;


namespace Server.Items
{
    public class SmallBedSouthAddon2 : BaseAddon2
    {
        AddonComponent2 ac;
        AddonComponent2 ac2;

        [Constructable]
        public SmallBedSouthAddon2()
        {

            AddonComponent2 ac;
            ac = new AddonComponent2(0xa63);
            ac.Movable = true;
            ac.Name = "Petit lit";
            AddComponent2(ac, 0, 0, 0);


            AddonComponent2 ac2;
            ac2 = new AddonComponent2(0xA5C);
            ac2.Movable = true;
            ac2.Name = "Petit lit";
            AddComponent2(ac2, 0, 1, 0);
        }

        public override void OnDoubleClick(Mobile from)
        {
            Mobile o;
            o = from;

            Item x;
            x = this;

            Item y;
            y = new SmallBedEastAddon2();

            int z;
            z = this.Hue;

            int w;
            w = from.GetWorldLocation;

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("vous êtes trop loin du lit");
            }
            else
            {
                from.SendGump(new ChristianMenuGump(o, x, y, z, w));
            }
        }

        public SmallBedSouthAddon2(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();
        }
    }
Code:
sing System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Items;

namespace Server.Gumps
{

    	public class ChristianMenuGump : Gump
	{
            Mobile m_Obj;
            private Item NewItem;
            private Item OldItem;
            private int RetainedHue;
            private int WorldPlace;

            public ChristianMenuGump(Mobile obj, Item OldFlippableItem, Item NewFlippedItem, int oldhue, int world): base(0, 0)
		{
            m_Obj = obj;
            NewItem = NewFlippedItem;
            OldItem = OldFlippableItem;
            RetainedHue = oldhue;
            WorldPlace = world;

			AddBackground( 265, 205, 320, 290, 5054 );
			Closable = true;
            Disposable = true;
            Dragable = true;
			Resizable = false;
			
			AddPage( 0 );      			
			
			AddImageTiled( 225, 175, 50, 45, 0xCE );   //Top left corner
			AddImageTiled( 267, 175, 315, 44, 0xC9 );  //Top bar
			AddImageTiled( 582, 175, 43, 45, 0xCF );   //Top right corner
			AddImageTiled( 225, 219, 44, 270, 0xCA );  //Left side
			AddImageTiled( 582, 219, 44, 270, 0xCB );  //Right side
			AddImageTiled( 225, 489, 44, 43, 0xCC );   //Lower left corner
			AddImageTiled( 267, 489, 315, 43, 0xE9 );  //Lower Bar
			AddImageTiled( 582, 489, 43, 43, 0xCD );   //Lower right corner

            AddPage(1);


            AddHtml(260, 254, 300, 140, "Voulez-vous tourner cet addon?", false, false);

            AddButton(260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 1);
            AddHtml(300, 300, 300, 50, "Oui", false, false);

            AddButton(360, 300, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
            AddHtml(400, 300, 300, 50, "Non", false, false);  
		}
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                if (m_Obj.InRange(GetWorldLocation(WorldPlace), 2))
                    {
                      m_Obj.SendMessage("Vous tournez le lit");
                      Item item = NewItem;
                      item.Hue = RetainedHue;
                      item.MoveToWorld(OldItem.Location, OldItem.Map);  
                      OldItem.Delete();
                    }
                    if (!m_Obj.InRange(GetWorldLocation(WorldPlace), 2))
                    m_Obj.SendMessage("vous êtes trop loin du lit");
            }

                if (info.ButtonID == 2)
                    return;
        }
	}
}

Last edited by Pantoute; 08-25-2008 at 09:57 AM.
Pantoute is offline   Reply With Quote
Old 08-25-2008, 04:43 PM   #29 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Check out the GetWorldLocation() method.

Well, you're having a problem with variable types.

GetWorldLocation() returns a three-part variable consisting of (X, Y, and Z) coordinates. It returns a Point3D. How do I know this? Google "runuo documenation getworldlocation".

It doesn't return an integer (like 1, 5, 23, 93, 2). Therefore, you're using the wrong variable type here:

Code:
            public ChristianMenuGump(Mobile obj, Item OldFlippableItem, Item NewFlippedItem, int oldhue, int world)
Siince you're passing a Point3D to your gump as an argument, just change the variable type to Location when creating your gump:

Code:
public ChristianMenuGump(Mobile obj, Item OldFlippableItem, Item NewFlippedItem, int oldhue, Point3D world): base(0, 0)
Also, since you're passing a Point3D, it's unnecessary to get the location of a Point3D later in the script. It already has a location... itself.

So... change this...
Code:
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                if (m_Obj.InRange(GetWorldLocation(WorldPlace), 2))
                    {
                      m_Obj.SendMessage("Vous tournez le lit");
                      Item item = NewItem;
                      item.Hue = RetainedHue;
                      item.MoveToWorld(OldItem.Location, OldItem.Map);  
                      OldItem.Delete();
                    }
                    if (!m_Obj.InRange(GetWorldLocation(WorldPlace), 2))
                    m_Obj.SendMessage("vous êtes trop loin du lit");
            }
to this...

Code:
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                if (m_Obj.InRange(WorldPlace, 2))
                    {
                      m_Obj.SendMessage("Vous tournez le lit");
                      Item item = NewItem;
                      item.Hue = RetainedHue;
                      item.MoveToWorld(OldItem.Location, OldItem.Map);  
                      OldItem.Delete();
                    }
                    if (!m_Obj.InRange(WorldPlace, 2))
                    m_Obj.SendMessage("vous êtes trop loin du lit");
            }
Let's double check the syntax for InRange() from the documentation (i.e. google "runuo documentation inrange"):
Code:
bool InRange( Point3D p, int range )
Ok, since we know that WorldPlace is a Point3D and 2 is an integer, it seems we fit the syntax.


These changes should sove your problem.

Last edited by Tassyon T; 08-25-2008 at 04:46 PM.
Tassyon T is offline   Reply With Quote
Old 08-25-2008, 08:39 PM   #30 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

Thank you very much. It'll help a lot. I didn't know that there was documentation on the defenitions of the methods. I'll check it out in the futur. Thanks.
Pantoute is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5