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!

Addon Script Generator

Arya

Wanderer
Addon Script Generator

Summary:
This script exports a structure built in game with static items to a working addon script. The output script will create both the addon and the addon deed. Hue and light information will be exported as well.


Description:
I wrote this little script to help me out in a bigger project (maybe someone else did this before, I was too lazy to search for it ;)). It basically creates a fully working script for an addon based on a structure built in game (the script extracts static items, which is what the deco section of Pandora's Box creates, and I believe also UOArchitect). The script preserves hue and light type for light sources.

It's very easy to use, the command is:

[AddonGen <name> [<namespace>]

<name> is the name of your object. It should not contain spaces (so if you want your structure called Tower Of Chaos, name would be TowerOfChaos - the script will then generated two items: TowerOfChaosAddon and TowerOfChaosAddonDeed).

<namespace> this is optional. By default the script will place the classes it creates into Server.Items, unless this parameter is specified.

Once the command is executed, you get an area picker to select the region you wish to export. The structure you're exporting will NOT be deleted.

The script will be written to ...\RunUO\TheBox\<name>Addon.cs.

Installation:
Just put AddonGenerator.cs anywhere in your Scripts folder.

Update May 29:
  • Fixed the error occurring when the output folder doesn't exit
  • Added an option to specify a custom output path at the beginning of the file

Update June 1:
I have added a gump interface to the command. Access the gump by using no arguments (in other words just type [AddonGen).

Through the gump you can specify whether you wish to export items and/or statics, and also a Z range. Keep in mind that when exporting statics hue information will be lost because RunUO doesn't load hue information from the statics*.mul files.
 

Attachments

  • AddonGenerator.cs
    12.7 KB · Views: 2,841

flowerbudd

Sorceror
I'm not worthy to even say your name out loud. You are just amazing. I am so thankful we have such talents in this community, thank you for sharing this
 

Arya

Wanderer
wraith said:
I assume this doesnt work on a structure frozen in the map?

No it doesn't, but I don't think it would be much trouble to do that. I'll try to add it if I have some free time.
 

flowerbudd

Sorceror
I'm sorry Arya, I am having a problem. I use PB to add items from the deco tab, ( for example a coffin, and when i try to do [addongen CoffinS and i target the boundaries it either tells me no items selected, or error writing file
 

Arya

Wanderer
flowerbudd said:
I'm sorry Arya, I am having a problem. I use PB to add items from the deco tab, ( for example a coffin, and when i try to do [addongen CoffinS and i target the boundaries it either tells me no items selected, or error writing file

The first issue occurs because you probably target an area which is only 1 tile wide (and the script thinks it's empty...). I could work around this, but if you specify an area slightly wider (at least 2 tiles) it will still work correctly. The script calculates the bounds according to the items it finds, not the area picked, so it's safe to select an area larger than the item itself.

The file writing error needs some investigating on the other hand. Please open the script and go to line 250. Change the block from:

Code:
catch
{
	from.SendMessage( 0x40, "An error occurred when writing the file." );
	fail = true;
}

to:

Code:
catch ( Exception err )
{
	Console.WriteLine( err.ToString() );
	from.SendMessage( 0x40, "An error occurred when writing the file." );
	fail = true;
}

Then please let me know what kind of error is reported on the console and I'll see if it's something I can fix in the script.
 

Dracarys

Wanderer
Overestimated? Nah...

Maybe a lot of people could have coded it.

But you DID code it. That's what matters.

So you are being loved now. Deal with it! *cough*
 

shorty12

Wanderer
*BOWS TO ARYA* i've been looking for something like this for along time, thanks again for another wonderful script!
 

Kizozen

Wanderer
flowerbudd said:
I'm sorry Arya, I am having a problem. I use PB to add items from the deco tab, ( for example a coffin, and when i try to do [addongen CoffinS and i target the boundaries it either tells me no items selected, or error writing file


I had the same error and fixed it by creating a new folder in the main RunUO directory labeled "TheBox"
 

David

Moderate
Hey come on guys! Rate these submissions!

This is like awesome stuff here and with 15 posts and over 40 downloads I was the first one to rate it? Come on, snap to it!
 

Final Realms

Wanderer
David said:
Hey come on guys! Rate these submissions!

This is like awesome stuff here and with 15 posts and over 40 downloads I was the first one to rate it? Come on, snap to it!

True... *snaps to it* wish more people would rate scripts... I know I rate those i truly enjoy *insert shameless plug here for people to go rate their favourite scripts :p * *end plug* :p :D ;)

Now back to Arya... Where exactly did you say you wanted the candles at, oh holy goddess of code? :D :D :cool:
 

Arya

Wanderer
I fixed the (stupid) error occurring when the output folder didn't exist, and also added an option to change the default output location at the beginning of the file.
 

Zigamus

Wanderer
I dont write scripts, yet, but I have been programming in basic for many years. Scanning your script I didnt see any mention of a MAX size this can handle. is it limited? and if so to what size plz? Also, does this handle ALL Z levels in the bounded box?
 

Arya

Wanderer
Zigamus said:
I dont write scripts, yet, but I have been programming in basic for many years. Scanning your script I didnt see any mention of a MAX size this can handle. is it limited? and if so to what size plz? Also, does this handle ALL Z levels in the bounded box?

I'm not sure I understand excatly what you mean by max size. If you're talking about the number of items you can put in the addon, I didn't set any limits. I don't think it's realistically possible to create an addon that will make the computer run out of memory. It would probably take more items than the client can handle anyway, so that shouldn't be an issue.

If you're talking about array sizes, I'm using an ArrayList object which is similar to an array but can grow in size when needed, therefore you don't have to specify a maximum size.

And yes, it does handle all Z levels.
 

Styla

Wanderer
Thanks. Now my wife won't kill me because I can't move her house from B36 to RCO 1.0. I bow to a true code master (and savior of marriages). :D
 
Top