Skip to content

Commit

Permalink
docs(general): Error in "layer_get_name" example
Browse files Browse the repository at this point in the history
YoYoGames/GameMaker-Bugs#6306

* Updated code example: fixed the issue and replaced DS list with array
* Updated function page a bit

(cherry picked from commit 6900952)
  • Loading branch information
YYBartT authored and gurpreetsinghmatharoo committed Aug 8, 2024
1 parent 6e67c57 commit 3e470c1
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>layer_get_name</title>
<meta name="generator" content="Adobe RoboHelp 2020" />
<meta name="generator" content="Adobe RoboHelp 2022" />
<link rel="stylesheet" href="../../../../../assets/css/default.css" type="text/css" />
<script src="../../../../../assets/scripts/main_script.js"></script>
<meta name="rh-authors" content="Mark Alexander" />
Expand All @@ -15,11 +15,12 @@
</head>
<body>
<!--<div class="body-scroll" style="top: 150px;">-->
<h1>layer_get_name</h1>
<p>You can use this function to get the <i>name</i> of the given layer. You supply the unique layer ID value and if the layer is one of the named layers created in the room editor, then the function will return a string with the layer name. If the layer is not one of the room editor ones (ie: it was created using <a href="layer_create.htm"><span class="inline">layer_create()</span></a>) then an empty string will be returned.</p>
<h1><span data-field="title" data-format="default">layer_get_name</span></h1>
<p>This function gets the name of the given layer.</p>
<p>You supply the unique layer ID value and if the layer is one of the named layers created in <a data-xref="{title}" href="../../../../../The_Asset_Editors/Rooms.htm">The Room Editor</a>, then the function will return a string with the layer name. If the layer is not one of the Room Editor ones (i.e.: it was created using <span class="inline3_func"><a data-xref="{title}" href="layer_create.htm">layer_create</a></span>) then an empty string <span class="inline2">&quot;&quot;</span> will be returned.</p>
<p> </p>
<h4>Syntax:</h4>
<p class="code">layer_get_name(layer_id)</p>
<p class="code"><span data-field="title" data-format="default">layer_get_name</span>(layer_id)</p>
<table>
<tbody>
<tr>
Expand All @@ -29,36 +30,36 @@ <h4>Syntax:</h4>
</tr>
<tr>
<td>layer_id</td>
<td><span data-keyref="Type_ID_Layer">Layer ID</span></td>
<td><span data-keyref="Type_ID_Layer"><a href="layer_get_id.htm" target="_blank">Layer</a></span></td>
<td>The unique ID value of the layer to get the name of</td>
</tr>
</tbody>
</table>
<p> </p>
<h4>Returns:</h4>
<p class="code"><span data-keyref="Type_String">String</span></p>
<p class="code"><span data-keyref="Type_String"><a href="../../../../GML_Overview/Data_Types.htm" target="_blank">String</a></span></p>
<p> </p>
<h4>Example:</h4>
<p class="code">var a = layer_get_all();<br />
var layer_list = ds_list_create(); for (var i = 0; i Alt; array_length(a); i++;)<br />
<p class="code">var _arr_layers = layer_get_all();<br />
var _arr_layers_named = [];<br />
for (var i = 0; i &lt; array_length(_arr_layers); i++)<br />
{<br />
    if layer_get_name(a[i]) != &quot;&quot;<br />
    if (layer_get_name(_arr_layers[i]) != &quot;&quot;)<br />
    {<br />
        ds_list_add(layer_list, a[i])<br />
        array_push(_arr_layers_named, _arr_layers[i]);<br />
    }<br />
}</p>
<p>The above code gets the IDs for all the layers in the room and then loops though them checking to see if any are named layers. If they are they are then their ID is added to a list.</p>
<p> </p>
<p>The above code gets the IDs of all the layers in the room and then loops through them to see if they&#39;re named layers. If they are they are then their ID is added to a list.</p>
<p> </p>
<p> </p>
<div class="footer">
<div class="buttons">
<div class="clear">
<div style="float:left">Back: <a href="General_Layer_Functions.htm">General Layer Functions</a></div>
<div style="float:right">Next: <a href="layer_get_all.htm">layer_get_all</a></div>
<div style="float:left">Back: <a data-xref="{title}" href="General_Layer_Functions.htm">Layers</a></div>
<div style="float:right">Next: <a data-xref="{title}" href="layer_get_all.htm">layer_get_all</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2022 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
layer_get_name
Expand Down

0 comments on commit 3e470c1

Please sign in to comment.