<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://www.gmlscripts.com:80/forums/extern.php?action=active&amp;type=RSS" rel="self" type="application/rss+xml" />
		<title><![CDATA[GMLscripts.com]]></title>
		<link>https://www.gmlscripts.com/forums/index.php</link>
		<description><![CDATA[The most recent topics at GMLscripts.com.]]></description>
		<lastBuildDate>Wed, 24 May 2023 08:59:26 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[String Concatenation/ Templates for GMS1]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2561&amp;action=new</link>
			<description><![CDATA[<p>Forgot to add the necessary script to make string_concat_var work. Added get_variable!</p>]]></description>
			<author><![CDATA[dummy@example.com (Soup Taels)]]></author>
			<pubDate>Wed, 24 May 2023 08:59:26 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2561&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[draw_collision_mask()]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2464&amp;action=new</link>
			<description><![CDATA[<p>For sure it doesn&#039;t as draw_rectangle doesn&#039;t draws rotated rectangles.</p>]]></description>
			<author><![CDATA[dummy@example.com (gnysek)]]></author>
			<pubDate>Thu, 09 Mar 2023 23:00:03 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2464&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Check if running on steamdeck]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2552&amp;action=new</link>
			<description><![CDATA[<p>For linux version, for sure this works:</p><div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">function is_deck(){
	var os = os_get_info();
	var _is_deck = false;
	if (os_type == os_linux) {
		if (ds_exists(os, ds_type_map)) {
			var _renderer_info = os[? &quot;gl_renderer_string&quot;];
			if ((_renderer_info != undefined) and string_pos(&quot;valve&quot;, _renderer_info) &gt; 1 and string_pos(&quot;neptune&quot;, _renderer_info) &gt; 1) {
				_is_deck = true;
			}
		}
	}
	ds_map_destroy(os);
	return _is_deck;
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (gnysek)]]></author>
			<pubDate>Thu, 09 Mar 2023 22:50:52 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2552&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[draw_sprite_animated]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2554&amp;action=new</link>
			<description><![CDATA[<p>Shouldn&#039;t it also take &quot;sprite_get_speed_type&quot; into account?</p>]]></description>
			<author><![CDATA[dummy@example.com (gnysek)]]></author>
			<pubDate>Thu, 09 Mar 2023 22:48:21 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2554&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[string_random_case]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2553&amp;action=new</link>
			<description><![CDATA[<p>Have a sarcastic character in your game? Want your text to be more unique? This may be helpful.</p><div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">/// string_random_case(str);
//
//  Convert each letter in a string to either uppercase or lowercase, at random.
//
/// GMLscripts.com/license
function string_random_case(str) {
    var origstring = str;
    var stringarray = [];
    var finalstring = &quot;&quot;;
    for(var i = 1; i &lt; string_length(origstring); i++) {
        stringarray[i] = string_char_at(origstring,i);
        stringarray[i] = choose(string_upper(stringarray[i]),string_lower(stringarray[i]));
        finalstring += stringarray[i];
    }
    return finalstring;
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (helloitscrash)]]></author>
			<pubDate>Tue, 07 Mar 2023 22:15:30 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2553&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Unix Time for Gamemaker Studio 2]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2551&amp;action=new</link>
			<description><![CDATA[<p>Hi all guys, I post a simple script to get unix time and convert it to human time.<br />Automatically calculate the time zone.</p><div class="codebox"><pre class="vscroll"><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">/// @func   get_unixtime()
/// @desc   Returns Unix timestamp.
function get_unixtime(){
    var timezone = date_get_timezone();
 
    date_set_timezone(timezone_utc);
    var epoch = floor(date_create_datetime(1970, 1, 1, 0, 0, 0));
    
    date_set_timezone(timezone);
    var datetime = date_current_datetime();
    
    var timestamp = floor(date_second_span(epoch, datetime));
 
    return timestamp;
}

/// @func   convert_unixtime(unix_timestamp)
/// @desc   Returns GameMaker datetime from Unix timestamp.
function convert_unixtime(timestamp){
    var timezone = date_get_timezone();
 
    date_set_timezone(timezone_utc);
    
    var epoch = date_create_datetime(1970, 1, 1, 0, 0, timestamp);
    var epH = date_get_hour(epoch);
    
    date_set_timezone(timezone);
    
    var cH = date_get_hour(date_current_datetime());
    
    var calcFuse = (cH - epH) * 3600;
    
    var datetime = date_create_datetime(1970, 1, 1, 0, 0, timestamp + calcFuse);
    return datetime;
}</code></pre></div><p>Example:</p><div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">var timestamp = get_unixtime();
draw_text(x,y,&quot;Unix time: &quot;+string(timestamp));

var datetime = convert_unixtime(timestamp);
draw_text(x,y+32,&quot;Human time: &quot;+string(date_datetime_string(datetime)));</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Kimera_V2)]]></author>
			<pubDate>Sat, 21 Jan 2023 12:26:16 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2551&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Draw a bent sprite]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2541&amp;action=new</link>
			<description><![CDATA[<p>I&#039;m not quite sure, but I&#039;ll need to check another way to soolve this problem.</p>]]></description>
			<author><![CDATA[dummy@example.com (Monvario)]]></author>
			<pubDate>Wed, 11 Jan 2023 12:05:29 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2541&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[pick]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2550&amp;action=new</link>
			<description><![CDATA[<p>A very small script that prevented tons of else-ifs/switches in certain situations</p><div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">/// pick(val, case1, return1, case2, return2, ...)
//
// returns one of the values or undefined
//
//     val - value to compare with
//     case&lt;x&gt; - compare this to val
//     return&lt;x&gt; - return this if case&lt;x&gt; equals to val
//     
/// GMLscripts.com/license

function pick() {
	var val = argument[0];
	for(var i = 1; i &lt; argument_count; i += 2) if argument[i] == val return argument[i+1];
	return undefined;
}</code></pre></div><p>Example:</p><div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">enum e_TYPE { A, B, C, D }

type = e_TYPE.C;
var c = pick(type, e_TYPE.A, c_red, e_TYPE.B, c_lime, e_TYPE.C, c_orange, e_TYPE.D, c_aqua);
draw_set_color(c);</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (maras)]]></author>
			<pubDate>Wed, 28 Dec 2022 21:42:06 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2550&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[drag_and_drop (for quickie debugging)]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2549&amp;action=new</link>
			<description><![CDATA[<p>Sometimes when testing stuff I need to move objects around that dont normally move. I always wished I could just drag them like a window so I made this script you can just drop at the step event.</p><div class="codebox"><pre class="vscroll"><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">/// drag_and_drop([button?])
//
//  Enables the object to be drag and dropped with the mouse around the room.
//
//      button?         Optional. Can be enabled if the sprite works as a button.
//                      ie. contains 2 images of a button being pressed.
//
/// GMLscripts.com/license
{
    var xx, yy, isbutton, hold, pressed, released;
    // Implement global vars
    if !variable_global_exists(&quot;cursor_dnd&quot;)
    {
        global.cursor_hover = noone;
        global.cursor_dnd = noone;
        global.cursor_xoffset = 0;
        global.cursor_yoffset = 0;
    }
    
    // variables
    xx = mouse_x;
    yy = mouse_y;
    isbutton = false;
    if(argument_count&gt;0) isbutton = argument[0];
    if isbutton image_speed = 0;
    
    // inputs
    hold = mouse_check_button(mb_left);
    pressed = mouse_check_button_pressed(mb_left);
    released = mouse_check_button_released(mb_left);
    
    // mark as hover instance
    if position_meeting(xx, yy, id) &amp;&amp; !instance_exists(global.cursor_hover)
    {
        global.cursor_hover = id;
    }
    if(global.cursor_hover == id)
    {
        if(!position_meeting(xx, yy, id))
            global.cursor_hover = noone;
    }
    
    // detect click
    if position_meeting(xx, yy, id) &amp;&amp; pressed &amp;&amp; !instance_exists(global.cursor_dnd)
    {
        global.cursor_dnd = id;
        global.cursor_xoffset = x-xx;
        global.cursor_yoffset = yy-y;
    }
    // dragging
    if(global.cursor_dnd == id)
    {
        x = xx+global.cursor_xoffset;
        y = yy-global.cursor_yoffset;
        if isbutton image_index = 1;
        if released
        {
            global.cursor_dnd = noone;
            if isbutton image_index = 0;
        }
    }
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (felres)]]></author>
			<pubDate>Fri, 16 Dec 2022 04:56:33 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2549&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Merge 2 lists, return 1. ds_list_merge(a,b)]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2528&amp;action=new</link>
			<description><![CDATA[<div class="quotebox"><cite>xot wrote:</cite><blockquote><div><p> I&#039;m somewhat surprised this doesn&#039;t already exist here. Perhaps someone else has submitted something like this in the past but it was never added.</p></div></blockquote></div><p>Right? I`ve actually wondered why the scripts have not been updated in so long!</p>]]></description>
			<author><![CDATA[dummy@example.com (felres)]]></author>
			<pubDate>Fri, 16 Dec 2022 04:47:36 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2528&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Script Submission Rules]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=45&amp;action=new</link>
			<description><![CDATA[<p>I believe that script style guide could be updated <img src="https://www.gmlscripts.com/forums/img/smilies/smile.gif" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (gnysek)]]></author>
			<pubDate>Tue, 25 Oct 2022 23:24:19 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=45&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[array_create_2d (2022.11+)]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2548&amp;action=new</link>
			<description><![CDATA[<div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">/// @param {Real} rows
/// @param {Real} cols
/// @param {Any*} value Default value
/// @returns {Array&lt;Array&lt;Any*&gt;&gt;)
function array_create_2d(rows, cols, value) {
    return array_create_ext(rows, method({c: cols, v: value}, function() {
        return array_create(c, v);
    }));
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (gnysek)]]></author>
			<pubDate>Mon, 24 Oct 2022 17:34:05 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2548&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[array_sum [2022.11+]]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2547&amp;action=new</link>
			<description><![CDATA[<div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">/// @desc returns sum of elements in array
/// @param {Array} a
function array_sum(a) {
	return array_reduce(a, function(p, v, i) {return p+v;});
}</code></pre></div><p>example:</p><div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">array_test = [10, 20, 70];
show_debug_message(array_sum(array_test));
// returns 10+20+70 = 100</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (gnysek)]]></author>
			<pubDate>Thu, 20 Oct 2022 22:10:11 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2547&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[array_shuffle]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=2546&amp;action=new</link>
			<description><![CDATA[<div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">/// @param {array} a
/// @returns {undefined}
function array_shuffle(a) {
	/// @returns {real}
	static _shuffle = function() {return choose(1, -1);}
	array_sort(a, _shuffle);
}</code></pre></div><p>usage:</p><div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">var a = [1, 2, 3, 4, 5, 6];
array_shuffle(a);
show_debug_message(a); // for example: [ 5,2,1,4,3,6 ]</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (gnysek)]]></author>
			<pubDate>Fri, 23 Sep 2022 08:40:38 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=2546&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Is_Prime]]></title>
			<link>https://www.gmlscripts.com/forums/viewtopic.php?id=76&amp;action=new</link>
			<description><![CDATA[<p>So, for 2022, most up-to-date version (including &lt;= fix) will be:</p><div class="codebox"><pre><span class="expand" onclick="expandCode(this)">Expand</span><code class="prettyprint lang-gml">/// @param {real} n number to check
/// @returns {bool}
function is_prime(n) {
    var a = [0, 2, 0, 4, 0, 2, 0, 2, 0, 2], p, m;
    if (n mod 2 == 0) return false;
    if (n mod 3 == 0) return false;
    p = 5;
    m = sqrt(n);
    while (p &lt;= m) {
    if (n mod p == 0) return false;
        p += a[p mod 10];
    }
    return true;
}</code></pre></div><p>??</p>]]></description>
			<author><![CDATA[dummy@example.com (gnysek)]]></author>
			<pubDate>Tue, 20 Sep 2022 16:24:22 +0000</pubDate>
			<guid>https://www.gmlscripts.com/forums/viewtopic.php?id=76&amp;action=new</guid>
		</item>
	</channel>
</rss>
