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!

RunUO with built in Script Library

Pyrochaser

Wanderer
RunUO with built in Script Library

This is a suggestion to the makers of RunUO. Believe me coming to these forums is a ton of fun but finding some scripts can be extremely difficult. My suggestion would be this; designing a way for all scripts applicable to it's version (ie 1.0, 2.0, svn) to be included into the scripts library, and the library having a way to select what scripts to run and what not. Like a visual basic executable that gives a list table with the library of scripts listed, descriptions of the script and what it does, and a box to check of if you want it to load on your server when executing RunUO. This could automatically included or remove the lines in and out of the different .cs files if edits are needed for certain files. Like an edit to playemobile.cs for example, the program would add the necessary lines and changes to the file when box is checked, and when box is unchecked it would remove them. Could add a folder to RunUO folders maybe called Library Scripts, the executable could move a script from this folder to scripts folder when the box is checked and when unchecked could move it back. Could also have an option built into it to import new scripts to add to the library, and compile a library file of the scripts to pass on to others or to upload to the forums for people to use as their template. I know this would be a heck of a lot of work, but i think it would be invaluable to those not well versed in scripting and editing lines of code. Basically it would be a RunUO for Dummies, allowing anyone to be able to construct a server in whatever fashion they dream it to be. Just a constructive idea, but I figure we are in a modern age of computers and programs things should get easier to set up, sure it takes the delight out of the work of constructing the scripts the old fashion way, but hey, easier it is more it will appeal to people and more we can continue to have the UO community grow. So special thanks to Ryan and the RunUO team, to all the owners, programmers, seers, and amazing servers out there, keep up the great ideas and fun events.
 

Arkryal

Wanderer
I know I'm bumping an ancient thread, but my suggestion was too similar to warrant a new thread.

A basic script repository in an SQL database to function like apt-get or similar Linux functions. Another example would be the FireFox addons manager. Even SVN clients function similarly (though some minor obvious differences do exist).

How it would function in theory:
A central database is created where users can store their script submissions.
The script is uploaded as raw text, and the poster fills out some info on it:
• Script contents
• Description
• External script dependancies (non-standard additional scripts required)
• Compatible version of Run UO
• Required Client Version
• URL linking to the forum post.

From there, we have a basic repository other scripts can access or users can interact with directly. Other variables can be tracked as well.
• Popularity (number of manual downloads)
• Good / Bad (let shard admins vote if it was stable or buggy etc.)

A player could then use an in-game command

[list addon scripts
presents a gump listing most popular systems. User scrolls through the list, finds one they like, clicks
"Install" and the script contents variable is parsed and written into a repository script folder. Likewise,
any listed dependancies are searched for within the database and downloaded / installed at the
same time.

[update
checks all scripts in the local repository folder for new versions and rechecks compatibility. If a new
script is available, it is downloaded and installed.

Other functions would be possible as well. Bug tracking would be very easy under this system. If there is a crash and a repository script is logged as the source, that log, along with the server version and a list of other non-standard scripts, their versions, time/date, and crash log are uploaded back to the database. This would enable developers to track their scripts stability on various server and client versions, in many circumstances and with variable player bases and custom script arrangements.

I know this sounds like a ton of work, but it's really not. Setting up a central database on a reliable server (and possibly some mirrors) would be bulk of it. Syncing mirrors is a pain in the ass, I admit. Beyond that, it's just a few read/write methods and some custom Gumps and commands. A core-mod for bugtracking may be needed to catch a fault, but it could be done outside the core as well with some file procedures. This is the type of thing C# was designed for.

This would be a godsend for SVN development.
 

greywolf79

Sorceror
I agree. I think it could help a lot to work on a database/library of scripts to make it easier to find things.

GreyWolf.
 

Arkryal

Wanderer
Well, I've got a proof of concept script now that compares a current script in the Custom folder of the install directory to a version key file on a web server. If the versions don't match it then reads each line from the current version on the server and writes them over the old file, saves the world and restarts the server.

It works great. Currently it's written to only check one specific file in one specific location, but could be easily expanded and an interface added.

I lack the SQL knowledge to write it securely, so for now it works from raw text files. My SQL pilot system was seemed vulnerable to injection code from a submitted script. One (intentionally) bad script could overwrite the whole repository. That's the problem with open sourcing such a system... everyone can see how it works.

However, the idea of using plain text files is becoming more appealing, as anyone could theoretically add a file through an ftp interface, and even use an ftp to sync files as they're saved from VS for collaborative work.

I'm in the middle of 3 large projects at the moment, and 2 more for another modding community, but when time becomes available, I'll revisit the idea and see if we can't set up an unofficial repository.

Here is the code I'm using:

Code:
using System;
using System.IO;
using System.Collections;
using Server;
using System.Collections.Generic;
using Server.Network;
using Server.Mobiles;
using System.Net;
using System.Text;


namespace Server.Commands
{
    public class GetVersion
    {
        public static void Initialize()
        {
            CommandSystem.Register("GetVersion", AccessLevel.Player, new CommandEventHandler(Get_Ver));
        }
        [Usage("GetVersion")]
        [Description("Check current Falconry Version")]
        public static void Get_Ver(CommandEventArgs e)
		{
            double currentversion = 0.0;
            StringBuilder sb = new StringBuilder();
            byte[] buf = new byte[8192];
            HttpWebRequest request = (HttpWebRequest)
                WebRequest.Create("http://www.thedevilsacolyte.com/version.info");
            HttpWebResponse response = (HttpWebResponse)
                request.GetResponse();
            Stream resStream = response.GetResponseStream();
            string tempString = null;
            int count = 0;

            do
            {
                count = resStream.Read(buf, 0, buf.Length);
                if (count != 0)
                {
                    tempString = Encoding.ASCII.GetString(buf, 0, count);
                    sb.Append(tempString);
                }
            }
            while (count > 0);

            double installedversion = 0.9;

            string svc = sb.ToString();
            currentversion = Convert.ToDouble(svc);
            if (e.Mobile is PlayerMobile)
            {
                PlayerMobile pm = (PlayerMobile)e.Mobile;
                if (currentversion > installedversion)
                {
                    pm.SendMessage("There is a new version of the Falconry system available for download");
                    StringBuilder sb2 = new StringBuilder();
                    byte[] buf2 = new byte[8192];
                    HttpWebRequest request2 = (HttpWebRequest)
                        WebRequest.Create("http://www.thedevilsacolyte.com/Falcon.cs");
                    HttpWebResponse response2 = (HttpWebResponse)
                        request2.GetResponse();
                    Stream resStream2 = response2.GetResponseStream();
                    string tempString2 = null;
                    int count2 = 0;
                    using (System.IO.StreamWriter file2 = new System.IO.StreamWriter(@"Scripts\Custom\Falcon.cs"))
                    {
                        do
                        {
                            count2 = resStream2.Read(buf2, 0, buf2.Length);
                            if (count2 != 0)
                            {
                                tempString2 = Encoding.ASCII.GetString(buf2, 0, count2);
                                file2.WriteLine(tempString2);
                            }
                        }
                        while (count2 > 0);
                        file2.Close();
                    }
                    Misc.AutoSave.Save();
                    pm.SendMessage("Install complete, world saved. Please restart the server");
                }
                else if (currentversion == installedversion)
                    pm.SendMessage("You are running the most recent version of the Falconry script.");
                else
                    pm.SendMessage("You are running an unofficial version of the Falconry script, you must update manually from the modder of the script.");
            }
        }
    }
}

As you can see, it looks for a version value in "version.info" on my website. that file contains the text "1.0". It reads that and returns the value as type double. That is compared to another version variable (hardcoded at the moment, will have to write a scanUserFileforVersion method) of version "0.9". It sees the installed version is less than the current version on my server and replaces the old file, saves the worls and prompts the user to restart the server.

It's primitive, lacking in elegance, and definitely bloated, but it works.

Edit:

To do list: (mostly just notes to my self, but if anyone wants to tackle any of these, go for it.)

• Need to set Byte length to be variable (it cuts off long lines, appending the remainder to a new line)
• Need to write a CheckLocalVersion method to get installed version info.
• Setup some error check if directories don't exist, (allow user to customize their custom folder location), check if file exists
etc.
• Gumps
• Currently is a command, would function better if it initialized automatically when admin logs on.
• Create a standard description for all files in comments at the top, this can be read into the gump. This would list dependencies, version info, Name, scripts to be added that were not in last install version, support url etc.
• A Package Script that formats the above comments correctly for reading. Perhaps a code cleaner to set standard indents and formatting (optional, but helpful for collaborative projects)
• A formalized web server directory structure, possible admin interface for upload and file management.
• Create backups of replaced scripts locally.
• A roll-back version option
• Server-end tracking of downloaded scripts for support and feedback to author
• Author has their own protected scripts, assigned by random key system. switch over to sealed functions for access (currently public) to prevent scripts from overriding server address variables, write locations etc.
• Hardcode all saves as type .cs, limit access to directories outside of runUO folder. (I imagine some kid writing a "del *.*" in the autoexec.bat or worse if filetype and directory access isn't restricted.)
• Present code in Gump so people updating have a chance to review changes in more detail than a description (helps deter malicious code, lets admins check to see if there would be any catastrophic errors with their existing systems etc)

Each step is easy to implement, but looking at them all at once... I see why no one's undertaken this yet. A lot of code for such a simple function, but it may be worth the pay-off. I'll spend some more time on it and post my results.
 
Top