General coding question

Discussions about Coding and Scripting
Post Reply
ShaiHulud
Adept
Posts: 459
Joined: Sat Dec 22, 2012 6:37 am

General coding question

Post by ShaiHulud »

Sorry, that's an awful topic title, but I couldn't think of anything better. I'm wondering, having had my first go at unreal scripting, whether any attempt has ever been made to create a community-driven library of useful functions and classes?

I know that i4games has put out some stuff, but one thing that I noticed when I was looking for examples of how to do things was the amount of duplication of work among all of the different mutators that I examined. I don't mean this to sound critical, it's just the way things have been done. But - to give an example - every mutator that wanted to keep track of players joining and leaving a server had it's own functions for iterating the Level.PawnList and keeping an array of in-game players during Tick() or with a Timer.

UT knows about player joins, is this not surfaced as an event that actors can listen out for? But anyway, the point is all of these mutators are independently polling away for exactly the same thing - wouldn't it make far more sense (especially if polling *is* the only way to do it) for one mutator to do the polling, and for every other mutator to make use of this and listen out for an event when player connects/disconnects were detected? Perhaps using BroadcastLocalizedMessage/MutatorBroadcastLocalizedMessage or else a scheme similar to BTPlusPlus with its "SendEvent"? This mutator (lets call it GameEvents or something) could let other listening mutators know when significant events occurred, and provide other relevant functions (perhaps Pawn/player name lookups, IP checks, Spectator or Player checks and so on).

And perhaps another for array functions: for sorting, searching and iterating arrays. Another again for Strings - with functions like "IsNumeric" "IsAlpha" "IsAlphaNumeric" "StrStartsWith" "StrEndsWith" and any other useful methods.

Perhaps there would be some "Manager" class that would spawn all of the child objects for each of these classes, and other mutators would create this first. Or all of these library mutators could have nothing but static functions (apologies if I'm confusing concepts and terminology here, it's early days).

Yes this would require some co-ordination, a single agreed code repository, an administrator or small team to decide what would go into these base classes. And yes they would probably go through a lot of iterations early on, but if everyone had these small compiled files, and used them in their mutators, it would get rid of a lot of overhead.

It might be best to attach a project like this to the Unreal Wiki rather than any single community. Thoughts? Flames?
User avatar
Sp0ngeb0b
Adept
Posts: 376
Joined: Wed Feb 13, 2008 9:16 pm
Location: Cologne
Contact:

Re: General coding question

Post by Sp0ngeb0b »

Nexgen tries to provides such a working frame, that's why I love developing plugins for it :)
Website, Forum & UTStats

Image
******************************************************************************
Nexgen Server Controller || My plugins & mods on GitHub
******************************************************************************
ShaiHulud
Adept
Posts: 459
Joined: Sat Dec 22, 2012 6:37 am

Re: General coding question

Post by ShaiHulud »

Ah excellent! Thanks Sp0nge, Nexgen crossed my mind when I was thinking about this earlier, so that's good to hear, I'll have to take a closer look at it.
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: General coding question

Post by Feralidragon »

Well, UnrealWiki has some, Shadow's SDK too (the UScript version, I think he had a class called sdkUtils or something similar with static functions alone), and NW3 has a class called NWUtils which has plenty of general purpose functions (well, the whole mod has rather generic classes, but NWUtils stands out as the most generic one).

I can't talk much about the others (since I never saw them in depth), but if you want to take a look at my NWUtils, just open the NW3 core package (NWCoreV3.u), then go to:
Actor > NaliWActor > NWUtils

The first functions are a bit specific to the mod itself (I only put them there since many classes used the same methods), but as you scroll down you will get to see generic functions to manipulate vectors, rotators and even strings.
An example of a function of string manipulation there is:

Code: Select all

//Check if string sA matches sB (having sA with wildcards like * and ?)
simulated static function bool StrMatch(string sA, string sB, optional bool bCaseSensitive){
...
}
Btw, if someone is wondering why I put "simulated" in static functions, is for the function to hold meaning (when I put simulated what I mean is that the function can be safely called from the client, if not, it means it's meant for server side only).

Anyway, if you intend to build a framework (which is a nice idea), or expand an existing one, feel free to rip and modify the functions you find useful from my class if you wish.
Relative UnrealWiki, you should also take a look at them since they are all free to use, and as for Shadow's demo SDK, you have to ask him if he agrees in you borrowing some functions from there.
ShaiHulud
Adept
Posts: 459
Joined: Sat Dec 22, 2012 6:37 am

Re: General coding question

Post by ShaiHulud »

Excellent post, thanks for all of that Feralidragon
Post Reply