1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Addon generator

Discussion in '3rd Party Support' started by Damien Darkwater, Feb 2, 2014.

  1. Damien Darkwater
    Offline

    Damien Darkwater New Member

    Joined:
    Jan 23, 2014
    Messages:
    28
    Likes Received:
    0
    I tried to install the addon generator and had these errors:

    Errors:
    + Customs/[2.0]AddonGenerator.cs:
    CS0101: Line 21: The namespace 'Arya.Misc' already contains a definition for
    'AddonGenerator'
    CS0102: Line 414: The type 'Arya.Misc.AddonGenerator' already contains a def
    inition for 'InternalGump'

    and here is the addon generator script, im sorry, I looked for other instances and found none in the folders. any help is appreciated, Thanx. sorry I don't know how to post the whole script here in the thread without attachment.so if the code don't work I added the attachment. thanx.

    here is the script:
    Code (C#):
    1.  
    2. //....................................//
    3. //...................................//
    4. //....Originally created by Arya....//
    5. //....Updated by Lucid Nagual......//
    6. //................................//
    7. //...............................//
    8. //Now saves item names and hues.
    9. using System;
    10. using System.Collections;
    11. using System.IO;
    12. using Server;
    13. using Server.Items;
    14. using Server.Gumps;
    15. using Server.Commands;
    16.  
    17. namespace Arya.Misc
    18. {
    19. publicclassAddonGenerator
    20. {
    21. ///<summary>
    22. /// Set this value if you wish the scripts to be output somewhere else rather than in the default RunUO\TheBox
    23. /// directory. This should be a full valid path on your computer
    24. ///
    25. /// Example:
    26. ///
    27. /// private static string m_CustomOutputDirector = @"C:\Program Files\RunUO\Scripts\Custom\Addons";
    28. ///</summary>
    29. privatestaticstring m_CustomOutputDirectory = null;
    30.  
    31. #region Template
    32. privateconststring m_Template = @"/////////////////////////////////////////////////
    33. // //
    34. // Automatically generated by the //
    35. // AddonGenerator script by Arya //
    36. // //
    37. /////////////////////////////////////////////////
    38. using System;
    39. using Server;
    40. using Server.Items;
    41. namespace {namespace}
    42. {
    43. public class {name}Addon : BaseAddon
    44. {
    45. public override BaseAddonDeed Deed
    46. {
    47. get
    48. {
    49. return new {name}AddonDeed();
    50. }
    51. }
    52. [ Constructable ]
    53. public {name}Addon()
    54. {
    55. {components}
    56. }
    57. public {name}Addon( Serial serial ) : base( serial )
    58. {
    59. }
    60. public override void Serialize( GenericWriter writer )
    61. {
    62. base.Serialize( writer );
    63. writer.Write( 0 ); // Version
    64. }
    65. public override void Deserialize( GenericReader reader )
    66. {
    67. base.Deserialize( reader );
    68. int version = reader.ReadInt();
    69. }
    70. }
    71. public class {name}AddonDeed : BaseAddonDeed
    72. {
    73. public override BaseAddon Addon
    74. {
    75. get
    76. {
    77. return new {name}Addon();
    78. }
    79. }
    80. [Constructable]
    81. public {name}AddonDeed()
    82. {
    83. Name = ""{name}"";
    84. }
    85. public {name}AddonDeed( Serial serial ) : base( serial )
    86. {
    87. }
    88. public override void Serialize( GenericWriter writer )
    89. {
    90. base.Serialize( writer );
    91. writer.Write( 0 ); // Version
    92. }
    93. public override void Deserialize( GenericReader reader )
    94. {
    95. base.Deserialize( reader );
    96. int version = reader.ReadInt();
    97. }
    98. }
    99. }";
    100.  
    101. #endregion
    102.  
    103. publicstaticvoid Initialize()
    104. {
    105. CommandSystem.Register( "AddonGen", AccessLevel.Administrator, new CommandEventHandler( OnAddonGen ) );
    106. }
    107. [ Usage( "AddonGen [<name> [namespace]]"),
    108. Description( "Brings up the addon script generator gump. When used with the name (and eventually namespace) parameter generates an addon script from the targeted region.") ]
    109. privatestaticvoid OnAddonGen( CommandEventArgs e )
    110. {
    111. //
    112. // State object:
    113. // 0: Name
    114. // 1: Namespace (Server.Items)
    115. // 2: Items (true)
    116. // 3: Statics (false)
    117. // 4: Use range (false)
    118. // 5: Min Z (-128)
    119. // 6: Max Z (127)
    120.  
    121. object[] state = newobject[ 7 ];
    122.  
    123. state[ 0 ] = "";
    124. state[ 1 ] = "Server.Items";
    125. state[ 2 ] = true;
    126. state[ 3 ] = false;
    127. state[ 4 ] = false;
    128. state[ 5 ] = -128;
    129. state[ 6 ] = 127;
    130. if ( e.Arguments.Length > 0 )
    131. {
    132. state[ 0 ] = e.Arguments[ 0 ];
    133. if ( e.Arguments.Length > 1 )
    134. {
    135. state[ 1 ] = e.Arguments[ 1 ];
    136. }
    137. BoundingBoxPicker.Begin( e.Mobile, new BoundingBoxCallback( PickerCallback ), state );
    138. }
    139. else
    140. {
    141. // Send gump
    142. e.Mobile.SendGump( new InternalGump( e.Mobile, state ) );
    143. }
    144. }
    145. privatestaticvoid PickerCallback( Mobile from, Map map, Point3D start, Point3D end, object state )
    146. {
    147. object[] args = state asobject[];
    148.  
    149. if ( start.X > end.X )
    150. {
    151. int x = start.X;
    152. start.X = end.X;
    153. end.X = x;
    154. }
    155. if ( start.Y > end.Y )
    156. {
    157. int y = start.Y;
    158. start.Y = end.Y;
    159. end.Y = y;
    160. }
    161. Rectangle2D bounds = new Rectangle2D( start, end );
    162.  
    163. string name = args[ 0 ] asstring;
    164. string ns = args[ 1 ] asstring;
    165.  
    166. bool items = (bool) args[ 2 ];
    167. bool statics = (bool) args[ 3 ];
    168. bool range = (bool) args[ 4 ];
    169.  
    170. sbyte min = sbyte.MinValue;
    171. sbyte max = sbyte.MaxValue;
    172.  
    173. try { min = sbyte.Parse( args[ 5 ] asstring ); }
    174. catch {}
    175. try { max = sbyte.Parse( args[ 6 ] asstring ); }
    176. catch {}
    177.  
    178. if ( max < min )
    179. {
    180. sbyte temp = max;
    181. max = min;
    182. min = temp;
    183. }
    184. Hashtable tiles = newHashtable();
    185.  
    186. if ( statics )
    187. {
    188. for ( int x = start.X; x <= end.X; x++ )
    189. {
    190. for ( int y = start.Y; y <= end.Y; y++ )
    191. {
    192. ArrayList list = map.GetTilesAt( new Point2D( x, y ), items, false, statics );
    193.  
    194. if ( range )
    195. {
    196. ArrayList remove = newArrayList();
    197.  
    198. foreach ( Tile t in list )
    199. {
    200. if ( t.Z < min || t.Z > max )
    201. remove.Add( t );
    202. }
    203. foreach( Tile t in remove )
    204. list.Remove( t );
    205. }
    206. if ( list != null && list.Count > 0 )
    207. {
    208. tiles[ new Point2D( x, y ) ] = list;
    209. }
    210. }
    211. }
    212. }
    213. IPooledEnumerable en = map.GetItemsInBounds( bounds );
    214. ArrayList target = newArrayList();
    215. bool fail = false;
    216.  
    217. try
    218. {
    219. foreach( object o in en )
    220. {
    221. Static s = o as Static;
    222.  
    223. if ( s == null )
    224. continue;
    225.  
    226. if ( range && ( s.Z < min || s.Z > max ) )
    227. continue;
    228. target.Add( o );
    229. }
    230. }
    231. catch ( Exception err )
    232. {
    233. Console.WriteLine( err.ToString() );
    234. from.SendMessage( 0x40, "The targeted items have been modified. Please retry." );
    235. fail = true;
    236. }
    237. finally
    238. {
    239. en.Free();
    240. }
    241. if ( fail )
    242. return;
    243.  
    244. if ( target.Count == 0 && tiles.Keys.Count == 0 )
    245. {
    246. from.SendMessage( 0x40, "No items have been selected" );
    247. return;
    248. }
    249. // Get center
    250. Point3D center = new Point3D();
    251. center.Z = 127;
    252. int x1 = bounds.End.X;
    253. int y1 = bounds.End.Y;
    254. int x2 = bounds.Start.X;
    255. int y2 = bounds.Start.Y;
    256.  
    257. // Get correct bounds
    258. foreach( Static item in target )
    259. {
    260. if ( item.Z < center.Z )
    261. {
    262. center.Z = item.Z;
    263. }
    264. x1 = Math.Min( x1, item.X );
    265. y1 = Math.Min( y1, item.Y );
    266. x2 = Math.Max( x2, item.X );
    267. y2 = Math.Max( y2, item.Y );
    268. }
    269. foreach( Point2D p in tiles.Keys )
    270. {
    271. ArrayList list = tiles[ p ] asArrayList;
    272.  
    273. foreach( Tile t in list )
    274. {
    275. if ( t.Z < center.Z )
    276. {
    277. center.Z = t.Z;
    278. }
    279. }
    280. x1 = Math.Min( x1, p.X );
    281. y1 = Math.Min( y1, p.Y );
    282. x2 = Math.Max( x2, p.X );
    283. y2 = Math.Max( y2, p.Y );
    284. }
    285. center.X = x1 + ( ( x2 - x1 ) / 2 );
    286. center.Y = y1 + ( ( y2 - y1 ) / 2 );
    287. // Build items
    288. System.Text.StringBuilder sb = new System.Text.StringBuilder();
    289.  
    290. // Statics
    291. foreach( Point2D p in tiles.Keys )
    292. {
    293. ArrayList list = tiles[ p ] asArrayList;
    294.  
    295. int xOffset = p.X - center.X;
    296. int yOffset = p.Y - center.Y;
    297.  
    298. foreach( Tile t in list )
    299. {
    300. int zOffset = t.Z - center.Z;
    301. int id = t.ID - 16384;
    302.  
    303. sb.AppendFormat( "\t\t\tAddComponent( new AddonComponent( {0} ), {1}, {2}, {3} );\n", id, xOffset, yOffset, zOffset );
    304. }
    305. }
    306. sb.AppendFormat( "\t\t\tAddonComponent ac;\n" );
    307.  
    308. foreach( Static item in target )
    309. {
    310. int xOffset = item.X - center.X;
    311. int yOffset = item.Y - center.Y;
    312. int zOffset = item.Z - center.Z;
    313. int id = item.ItemID;
    314.  
    315. sb.AppendFormat( "\t\t\tac = new AddonComponent( {0} );\n", item.ItemID );
    316.  
    317. if ( ( item.ItemData.Flags & TileFlag.LightSource ) == TileFlag.LightSource )
    318. {
    319. sb.AppendFormat( "\t\t\tac.Light = LightType.{0};\n", item.Light.ToString() );
    320. }
    321. if ( item.Hue != 0 )
    322. {
    323. sb.AppendFormat( "\t\t\tac.Hue = {0};\n", item.Hue );
    324. }
    325. if ( item.Name != null )
    326. {
    327. sb.AppendFormat( "\t\t\tac.Name = \"{0}\";\n", item.Name );
    328. }
    329. sb.AppendFormat( "\t\t\tAddComponent( ac, {0}, {1}, {2} );\n", xOffset, yOffset, zOffset );
    330. }
    331. string output = m_Template.Replace( "{name}", "AG_" + name );
    332. output = output.Replace( "{namespace}", ns );
    333. output = output.Replace( "{components}", sb.ToString() );
    334.  
    335. StreamWriter writer = null;
    336. string path = null;
    337.  
    338. if ( m_CustomOutputDirectory != null )
    339. path = Path.Combine( m_CustomOutputDirectory, string.Format( @"TheBox\{0}Addon.cs", name ) );
    340. else
    341. path = Path.Combine( Core.BaseDirectory, string.Format( @"TheBox\{0}Addon.cs", name ) );
    342.  
    343. fail = false;
    344.  
    345. try
    346. {
    347. string folder = Path.GetDirectoryName( path );
    348.  
    349. if ( ! Directory.Exists( folder ) )
    350. {
    351. Directory.CreateDirectory( folder );
    352. }
    353. writer = newStreamWriter( path, false );
    354. writer.Write( output );
    355. }
    356. catch
    357. {
    358. from.SendMessage( 0x40, "An error occurred when writing the file." );
    359. fail = true;
    360. }
    361. finally
    362. {
    363. if ( writer != null )
    364. writer.Close();
    365. }
    366. if ( ! fail )
    367. {
    368. from.SendMessage( 0x40, "Script saved to {0}", path );
    369. }
    370. }
    371. #region Gump
    372. privateclassInternalGump : Gump
    373. {
    374. privateconstint LabelHue = 0x480;
    375. privateconstint GreenHue = 0x40;
    376. privateobject[] m_State;
    377.  
    378. public InternalGump( Mobile m, object[] state ) : base( 100, 50 )
    379. {
    380. m.CloseGump( typeof( InternalGump ) );
    381. m_State = state;
    382. MakeGump();
    383. }
    384. privatevoid MakeGump()
    385. {
    386. this.Closable=true;
    387. this.Disposable=true;
    388. this.Dragable=true;
    389. this.Resizable=false;
    390. this.AddPage(0);
    391. this.AddBackground(0, 0, 280, 225, 9270);
    392. this.AddAlphaRegion(10, 10, 260, 205);
    393. this.AddLabel(64, 15, GreenHue, @"Addon Script Generator");
    394. this.AddLabel(20, 40, LabelHue, @"Name");
    395. this.AddImageTiled(95, 55, 165, 1, 9304);
    396.  
    397. // Name: 0
    398. this.AddTextEntry(95, 35, 165, 20, LabelHue, 0, m_State[ 0 ] asstring );
    399.  
    400. this.AddLabel(20, 60, LabelHue, @"Namespace");
    401. this.AddImageTiled(95, 75, 165, 1, 9304);
    402.  
    403. // Namespace: 1
    404. this.AddTextEntry(95, 55, 165, 20, LabelHue, 1, m_State[ 1 ] asstring );
    405.  
    406. // Items: Check 0
    407. this.AddCheck(20, 85, 2510, 2511, ((bool) m_State[2]), 0);
    408. this.AddLabel(40, 85, LabelHue, @"Export Items");
    409.  
    410. // Statics: Check 1
    411. this.AddCheck(20, 110, 2510, 2511, ((bool) m_State[3]), 1);
    412. this.AddLabel(40, 110, LabelHue, @"Export Statics");
    413.  
    414. // Range: Check 2
    415. this.AddCheck(20, 135, 2510, 2511, ((bool) m_State[4]), 2);
    416. this.AddLabel(40, 135, LabelHue, @"Specify Z Range");
    417.  
    418. // Min Z: Text 2
    419. this.AddLabel(50, 160, LabelHue, @"min.");
    420. this.AddImageTiled(85, 175, 60, 1, 9304);
    421. this.AddTextEntry(85, 155, 60, 20, LabelHue, 2, m_State[5].ToString() );
    422.  
    423. // Max Z: Text 3
    424. this.AddLabel(160, 160, LabelHue, @"max.");
    425. this.AddImageTiled(200, 175, 60, 1, 9304);
    426. this.AddTextEntry(200, 155, 60, 20, LabelHue, 3, m_State[6].ToString());
    427.  
    428. // Cancel: B0
    429. this.AddButton(20, 185, 4020, 4021, 0, GumpButtonType.Reply, 0);
    430. this.AddLabel(55, 185, LabelHue, @"Cancel");
    431.  
    432. // Generate: B1
    433. this.AddButton(155, 185, 4005, 4006, 1, GumpButtonType.Reply, 0);
    434. this.AddLabel(195, 185, LabelHue, @"Generate");
    435. }
    436. publicoverridevoid OnResponse(Server.Network.NetState sender, RelayInfo info)
    437. {
    438. if ( info.ButtonID == 0 )
    439. return;
    440.  
    441. foreach( TextRelay text in info.TextEntries )
    442. {
    443. switch ( text.EntryID )
    444. {
    445. case 0: // Name, 0
    446. m_State[ 0 ] = text.Text;
    447. break;
    448.  
    449. case 1: // Namespace, 1
    450. m_State[ 1 ] = text.Text;
    451. break;
    452.  
    453. case 2: // Min Z, 5
    454. m_State[ 5 ] = text.Text;
    455. break;
    456.  
    457. case 3: // Max Z, 6
    458. m_State[ 6 ] = text.Text;
    459. break;
    460. }
    461. }
    462. // Reset checks
    463. m_State[ 2 ] = false;
    464. m_State[ 3 ] = false;
    465. m_State[ 4 ] = false;
    466.  
    467. foreach( int check in info.Switches )
    468. {
    469. m_State[ check + 2 ] = true; // Offset by 2 in the state object
    470. }
    471. if ( Verify( m_State ) )
    472. {
    473. BoundingBoxPicker.Begin( sender.Mobile, new BoundingBoxCallback( AddonGenerator.PickerCallback ), m_State );
    474. }
    475. else
    476. {
    477. sender.Mobile.SendMessage( 0x40, "Please review the generation parameters, some are invalid." );
    478. sender.Mobile.SendGump( new InternalGump( sender.Mobile, m_State ) );
    479. }
    480. }
    481. privatestaticbool Verify( object[] state )
    482. {
    483. if ( state[ 0 ] == null || ( state[ 0 ] asstring ).Length == 0 )
    484. returnfalse;
    485.  
    486. if ( state[ 1 ] == null || ( state[ 1 ] asstring ).Length == 0 )
    487. returnfalse;
    488.  
    489. bool items = (bool) state[ 2 ];
    490. bool statics = (bool) state[ 3 ];
    491. bool range = (bool) state[ 4 ];
    492. sbyte min = sbyte.MaxValue;
    493. sbyte max = sbyte.MinValue;
    494. bool fail = false;
    495.  
    496. try
    497. {
    498. min = sbyte.Parse( state[ 5 ] asstring );
    499. }
    500. catch { fail = true; }
    501.  
    502. try
    503. {
    504. max = sbyte.Parse( state[ 6 ] asstring );
    505. }
    506. catch { fail = true; }
    507.  
    508. if ( ! ( items || statics ) )
    509. returnfalse;
    510.  
    511. if ( range && fail )
    512. returnfalse;
    513.  
    514. returntrue;
    515. }
    516. }
    517. #endregion
    518. }
    519. }
    520. [code]
     

    Attached Files:

  2. IanE
    Offline

    IanE Member

    Joined:
    Dec 27, 2013
    Messages:
    220
    Likes Received:
    16
    An error like that means you have that being used somewhere else I believe.
     
    • Creative Creative x 1
  3. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    282
    Likes Received:
    32
    You are getting that error because you already have the AddonGenerator script. Do you have Nerun's already installed? If so his distro includes the AddonGenerator built into it. The one included in Nerun's is also more up to date than the one you posted.
     
  4. Damien Darkwater
    Offline

    Damien Darkwater New Member

    Joined:
    Jan 23, 2014
    Messages:
    28
    Likes Received:
    0
    ok I found it ty for the help it was in my nerun's that's why I didn't find it . so now I know that if I see that type of error I need to start looking to see if I have any other instances of that script running, thank you for helping me see the error in my ways.
     
Similar Threads: Addon generator
Forum Title Date
Custom Releases AddonGenerator through High Seas Mar 15, 2015
Custom Releases Addon Generator by CEO Dec 8, 2013
Script Support Addstairs addon Wednesday at 7:22 AM
Archived Bug Reports Bug report when using the resize house command in regards to addons Jul 12, 2017
Custom Releases XWorld (XSpawner Addon or Standalonee) May 16, 2017
New Join Forum Core Addons Mar 23, 2017
3rd Party Discussions UO-Fiddler addons and fit-for-the-future versions Feb 28, 2017