Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C#

C# C# Discussion

Reply
 
Thread Tools Display Modes
Old 01-03-2006, 06:26 AM   #1 (permalink)
Forum Expert
 
nomad707's Avatar
 
Join Date: Mar 2003
Location: Santa Rosa, CA
Age: 21
Posts: 1,568
Send a message via AIM to nomad707 Send a message via MSN to nomad707 Send a message via Yahoo to nomad707
Default Making a setting file, for any script [guide]

making a setting file for any SET of scripts, is quite easy. It has been used on some scripts, such as dupres tokens. I used it in my race system, token system, and a few other things i scripted. Yes, it might be a tad sloppy, and a little un-needed, but also, when you use a setttings script, you can change many factors, for many many many scripts, by changing one line.

How to do it:
First off, we will say, this script defines hue.
Now, for the public class, generally you should have this match or be the subject of the setting file, so you dont get confused. Now. the way this works, is Very basic.
The public class:
The public class Csetting defines Which file csetting is, so that Chue=2971 may be located later on.
How you can call upon the custom hue in other files :
Hue = Csetting.Chue;

This settings system, may be usefull to larger scripts, or systems, that have alot of different items. I like to use the "hue" feature, shown in this script, to keep orginization, so when players see that hue, they know it is something to do, with the overall system.

using System;
using Server;
using Server.Network;
using Server.Items; <--- Hue for items will be used
using Server.Mobiles; <--- Hue for Mobiles will be used

namespace Server.Misc
{
public class Csetting
{
public static int Chue=2971; //////2971 indicates hue
}
}


I am getting back into c# again, do not flame, as i will ignore your post and let you think you are tough.
__________________
Northern Born, Livin in the ghetto

Last edited by nomad707; 01-03-2006 at 06:29 AM.
nomad707 is offline   Reply With Quote
Old 01-03-2006, 01:12 PM   #2 (permalink)
Forum Expert
 
TheOutkastDev's Avatar
 
Join Date: Sep 2002
Location: Houston, Texas
Age: 22
Posts: 3,933
Default

Unless you'd be loading settings from a file, its better to use public const int for these types of variables. Whenever the script is compiled and integer is read as being constant, the compiler will make sure that in other parts of the code no attempt is made to alter its value.
TheOutkastDev is offline   Reply With Quote
Old 01-04-2006, 01:07 AM   #3 (permalink)
Forum Expert
 
Join Date: Sep 2002
Age: 23
Posts: 1,472
Default

Just so you know, most of your "using" statements are not necessary. You would need to put:

using Server.Misc;

... on any script that you wanted to use your CSetting class with, like below:

Code:
namespace Server.Misc
{
	public class CSetting
	{
		public const int BODBlack = 0x497; // which may or may not be the correct hue, its been a while...
	}
}
To use it, you would do the following:

Code:
using Server.Misc;

 ...

this.Hue = CSetting.BODBlack;

Or:

Code:
this.Hue = Server.Misc.CSetting.BODBlack;
Ravatar is offline   Reply With Quote
Old 01-04-2006, 01:26 AM   #4 (permalink)
Forum Expert
 
nomad707's Avatar
 
Join Date: Mar 2003
Location: Santa Rosa, CA
Age: 21
Posts: 1,568
Send a message via AIM to nomad707 Send a message via MSN to nomad707 Send a message via Yahoo to nomad707
Default

ah cool thanks for the info =D
__________________
Northern Born, Livin in the ghetto
nomad707 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