RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Making glass jugs fillable

Mr_Rappa

Wanderer
Making glass jugs fillable

Hi,

In Scripts/Items/Food/BeverageEmpty.cs there's the details for an empty glass jug (among other things)

I'd like to make this so that you can fill it from any water source like you can on OSI - ie double click and target a water tile/water trough and it is refilled with water. A lot of players are finding it awkward to keep themselves refreshed (as drinking is required as well as eating) and being able to refill an item would be an advantage.

I know I probably need to add a line like:[code:1]
public override void OnDoubleClick( Mobile from )
[/code:1]


But after that I'm lost.

Can someone point me in the right direction? Or give me an example to work off?

Thanks in advance.....


P.S. Yes - I have already done a search.
 
D

DragonGrove

Guest
Still not refillable

Well... I got my lovely plant seeds spawning.. went and filled up some special pots.. placed a watertrough on my roof, layed oput all my gardening tools, bought a pticher of water.. and went to work.. and then the worl abruptly stopped.. lol.. Waddaya mean I can't refill a pitcher????

LOL.. but anywho.. since this still isn't workin (far as I can find) anyone have any ideas on this? It would be especially nice if you are planning on putting the plants into your shard. *thinks of all the hundreds of empty ptichers gonna end up on the sidewalks and shudders*

We really gonna need a fix for this one.. *starts tinkering with the script hoping she gets lucky*
 

BlahGoD

Wanderer
[code:1]
[FlipableAttribute( 0xff6, 0xff7 )]
public class GlassPitcher : Item
{
[Constructable]
public GlassPitcher() : base( 0xff6 )
{
this.Weight = 0.3;
}

public GlassPitcher( 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 override void OnDoubleClick( Mobile from )
{
if ( !Movable )
return;

from.SendLocalizedMessage( 500837 );
from.Target = new InternalTarget( this );
}

private class InternalTarget : Target
{
private GlassPitcher m_Item;

public InternalTarget( GlassPitcher item ) : base( 1, false, TargetFlags.None )
{
m_Item = item;
}

protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Item.Deleted ) return;

if ( targeted is WaterBarrel )
{

if( ((WaterBarrel)targeted).Water > 1 )
{
((WaterBarrel)targeted).Water--;
m_Item.Delete();
from.AddToBackpack( new PitcherWater() );
}

else if ( ((WaterBarrel)targeted).Water == 1 )
{
((WaterBarrel)targeted).Water--;
((WaterBarrel)targeted).Movable = true;
((WaterBarrel)targeted).ItemID = 0xE77;
m_Item.Delete();
from.AddToBackpack( new PitcherWater() );
}


}
}
}
}
[/code:1]

thats what i use for my water barrel script but edit it to be whatever you want, should give you an idea maybe?
 

Ra'Thine

Wanderer
I understand why you used the waterbarrel. I am having trouble making one however. would you mind sharing your water barrel script?
 
D

DragonGrove

Guest
I had a hard time with this too.. tried to change the waterbarrel to a watertrough.. seemed to be okay.. But I can't find the original waterpitcher to replace.. looked in beverages and its not there.. get a whole mess of errors
 

Ra'Thine

Wanderer
Well, you need to change the EmptyBeverages not beverages anyway.
well I can't plant something anyway, but it doesn't seem to grow.
 
D

DragonGrove

Guest
I have to many plants gorwing currently, hehe.. and daily i throw away about forty empty pitchers. Not sure what problems you are having with the plants but mine are working great

so I will find the emptypitcher I need to replace in emptybeverages.. ty ty
maybe it will work this time. *sigh*

thanks again,
proven script dummy
 

BlahGoD

Wanderer
i never read these boards that much sorry

[code:1]
using System;

namespace Server.Items
{
public class WaterBarrel : Item
{

private int i_Water;

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

[Constructable]
public WaterBarrel() : base( 0x154D )
{
Weight = 5.0;
Water = 20;
Movable = false;

}

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

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

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

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

int version = reader.ReadInt();
i_Water = (int)reader.ReadInt();
}
}
}
[/code:1]

this is the PitcherWater object in cooking.cs
[code:1] // ********** PitcherWater **********
public class PitcherWater : Item
{
[Constructable]
public PitcherWater() : base(Utility.Random( 0x1f9d, 2 ))
{
Weight = 1.0;
}

public PitcherWater( 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 override void OnDoubleClick( Mobile from )
{
if ( !Movable )
return;

from.Target = new InternalTarget( this );
}

private class InternalTarget : Target
{
private PitcherWater m_Item;

public InternalTarget( PitcherWater item ) : base( 1, false, TargetFlags.None )
{
m_Item = item;
}

protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Item.Deleted ) return;

if ( targeted is BowlFlour )
{
m_Item.Delete();
((BowlFlour)targeted).Delete();

from.AddToBackpack( new Dough() );
from.AddToBackpack( new WoodenBowl() );
from.AddToBackpack( new GlassPitcher() );
}
else if ( targeted is WaterBarrel )
{
if ( ((WaterBarrel)targeted).Water < 20 )
{
((WaterBarrel)targeted).Water++;
((WaterBarrel)targeted).Movable = false;
m_Item.Delete();
from.AddToBackpack( new GlassPitcher() );
((WaterBarrel)targeted).ItemID = 0x154D;
}
}
}
}
}[/code:1]
 

Rogue

Wanderer
I am fairly new to scripting, but did add your script for Glass Pitcher, or tryed to. I got an error saying that in line 69- the "target" was not known.
Has anyone else encountered this problem?
I can add waterBarrels- just so far cannot fill pitchers with water from them yet. Any help would be appreciated.
 
Top