Asset - Scripts Script Essentials - 20+ free scripts to make life easier

NAL

ʕ ᓀ ᴥ ᓂ ʔ
GMC Elder
Script Essentials is a pack of 20+ scripts intended to speed up repetitive implementations and generally help you circumvent potential bugs before they ever occur.



Script Essentials contains the following scripts:

draw_text_fit(): draws a string of text. If that string of text is wider (in pixels) than a given width, it will be scaled horizontally until it fits. Good for custom input boxes.

draw_text_font(): draws a string of text in the given font - shortcuts the extra call if you're switching fonts a lot

draw_text_align(): draws a string of text with the given horizontal and vertical alignment - shortcuts the two extra calls if you're changing alignment a lot

draw_text_custom(): draws a string of text with both font and h/v alignment options

draw_text_circle(): draws text around a circle. Contains arguments to define the angle of the first character, the radius of the circle etc.

draw_text_outline(): draws text with a customisable outline (colour, thickness, fidelity). This works the quick and dirty way - drawing the text multiple times to form the outline - but will be compatible with the worst PCs out there where an optimised shader outline might not be, and won't cause any real performance dips unless you're using it excessively or with a very high fidelity

draw_text_shadow(): draws text with a customisable shadow - can handle drop or solid shadows, direction, distance, colour and fidelity

string_max_length(): returns a string of text shortened to a given number of characters. A handy shortcut script for user inputs where you want to impose a character limit

string_zeroes(): returns a string with zeroes leading the front until it reaches a given number of characters. Useful for dealing with things such as times (where five past two is 02:05 rather than 2:5), as well as old-school score displays where the number of digits displayed remains consistent (starting at, eg, 00000000)

string_thousands(): returns a string which is a real value with thousand separators added. A very useful one for making long numbers more readable and understandable, as thousand separators do in real world situations too

string_time(): takes a number of steps/frames and returns a string of that number of steps in equivalent real time, with centiseconds, seconds, and minutes (if the result makes that necessary)

string_blatter(): more of a polish script than a shortcut, string_blatter will move one string towards a second target string in a jittery but also smooth way. This is a great one for menus where you flick through eg. a list of levels - you can have the displayed information about the level transition smoothly towards the new information. This one's worth looking at the example included to see how it works

string_real_abbreviate(): takes a real number and returns a simplified, abbreviated version of it if it's greater than 1,000, with options for accuracy. So 13,762,102 might be returned as "13.7m". The function can shorten up to sextillions (1,000,000,000,000,000,000,000), although is easily altered if for whatever reason you require more than that

clerp(): combines the clamp and lerp functions. I use lerp for smooth movement - instead of, say, objPlayer.x=500, I might go "objPlayer.x=lerp(objPlayer.x,500,0.2)". The downside is that it will move too quickly to begin with, and too slowly at the end. Clerp means that it has a maximum and minimum "speed" when moving towards its destination - and if it is so close that the minimum speed will cause it to overshoot, it then simply jumps to the location and stops moving from there on

percent(): returns true with a given % chance

set_best_aa(): tests the computer for the best multiplication of anti-aliasing that it can handle, and sets the game's AA to that. Lets you define whether vsync is enabled or disabled simultaneously

real_roundto(): returns a given real number rounded to the nearest other given number, eg 58 to the nearest 10 will return 60

real_sigfigs(): returns a given real number simplified to the given number of significant figures

nput(): used for polling whether commands are pressed. Nput is a system for easily taking PC, Mac and Linux keyboard-based games and making them gamepad-compatible with no significant effort. nput() is the function used for checking if given things are pressed, eg K_LEFT (which will return true on vk_left, gp_padl or left analogue stick pushed left

nput_init(): called once on game launch if you wish to use Nput (see above)

nput_repeater(): called each step after Nput is initialised (see above). This controls the repeater, which is necessary for analogue stick inputs but also used for repeating inputs (if you hold one of the directions down, it will start repeating the Pressed trigger, so on menus you can toggle through things quickly)

Download Script Essentials
 
Top