-
Notifications
You must be signed in to change notification settings - Fork 6
Little Helpers
This is a group of helper functions that did not fit anywhere else and are too few (and too small) to get their own script for each.
Test, if the specified value
is between the lower_bound
and the upper_bound
, where is_between
tests the range including
both bounds, and is_between_ex
tests excluding
both bounds.
/// @function is_between[_ex](val, lower_bound, upper_bound)
/// @description test if a value is between lower and upper bounds
/// @param {real/int} value
/// @param {real/int} lower_bound
/// @param {real/int} upper_bound
/// @returns {bool} y/n
/// @function is_any_of(val, ...)
/// @description Specify any number of parameters after "val".
/// Determines if val is equal to any of them.
/// @param {any} val The value to find
/// @param {any} ... List of values to search
/// @returns {bool} y/n
Gets, how many % value
is of total
.
percent
returns the full value (Example: val 30, total 50 -> returns 60(%)) and
percent_mult
returns a multiplier for the value, so 0.6
instead of 60
.
/// @function percent(val, total)
/// @description Gets, how many % "of" is of "total"
/// @param {real} val The value
/// @param {real} total 100%
/// @returns {real} How many % of total is val. Example: val 30, total 50 -> returns 60(%)
GameMaker's object_is_ancestor
has a little flaw: It returns false
if the object is exactly the ancestor. If you test object_is_ancestor(myGameObject, myGameObject)
you receive false
because it is not derived from myGameObject
.
This function here will return true in this case (and also uses object_is_anchestor
, so you get the same results, except that the case child==parent
also returns true
.
/// @function is_child_of(child, parent)
/// @description True, if the child is exactly parent type or derived from it
/// @param {object_index} child
/// @param {object} parent
/// @returns {bool}
Raptor core: Macros ● Logger ● Controllers ● LG Localization ● RACE (The Random Content Engine) ● Savegame System
Game modules: UI Subsystem ● Animation ● StateMachine ● Shaders ● Particle Effects ● Tools, other Objects and Helpers
Back to Repo ● Wiki Home ● Copyright © coldrock.games