Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jan 30, 2025
2 parents bab0a66 + f787a7d commit 8e54793
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ <h1><span data-field="title" data-format="default">all</span></h1>
mp_grid_add_instances(grid, all, false);
</p>
<p><span class="inline2">all</span> is a very useful keyword and can be used in numerous situations within your code and actions, often cutting down on the amount of code you need to write to achieve a desired effect.</p>
<p>Also see: <a data-xref="{text}" href="../Instance_Keywords.htm#h">Legacy Values</a></p>
<p> </p>
<p> </p>
<div class="footer">
Expand All @@ -40,7 +41,7 @@ <h1><span data-field="title" data-format="default">all</span></h1>
<div>Next: <a data-xref="{title}" href="noone.htm">noone</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2025 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ <h1><span data-field="title" data-format="default">noone</span></h1>
<p class="code">ins_last_collided_with = noone;</p>
<p class="code_heading">Collision Event</p>
<p class="code">ins_last_collided_with = other.id;</p>
<p>Also see: <a data-xref="{text}" href="../Instance_Keywords.htm#h">Legacy Values</a></p>
<p> </p>
<p> </p>
<div class="footer">
Expand All @@ -41,7 +42,7 @@ <h1><span data-field="title" data-format="default">noone</span></h1>
<div>Next: <a data-xref="{title}" href="self.htm">self</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2025 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
noone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ <h1><span data-field="title" data-format="default">other</span></h1>
<li>Anywhere else, this is the previous scope before the <span class="inline2"><a href="self.htm">self</a></span> changed, for example, the instance or struct that executed a <span class="inline2"><a data-xref="{title}" href="../Language_Features/with.htm">with</a></span> statement or called a bound method. As such it is only useful in those specific cases and outside of those cases it remains the same as <span class="inline2">self</span>.</li>
</ul>
<p><span class="inline2">other</span> has multiple ways that it can be used to reference a specific instance or struct: it can be used in a <span class="inline2"><a data-xref="{title}" href="../Language_Features/with.htm">with</a></span> statement, in a <a href="../../../The_Asset_Editors/Object_Properties/Object_Events.htm">collision event</a>, or in a function. This page is going to explain the last two use cases.</p>
<p>Also see: <a data-xref="{text}" href="../Instance_Keywords.htm#h">Legacy Values</a></p>
<h2>Collision Event</h2>
<p>A collision event can only happen between <strong>two </strong>instances. You <i>can</i> have multiple collisions between multiple instances, but they are all resolved by <span data-keyref="GameMaker Name">GameMaker</span> on a 1-on-1 basis, with the &quot;self&quot; instance that has the collision event and the &quot;other&quot; instance that is colliding with it.</p>
<p>Imagine you have a player instance, multiple enemy instances and multiple bullet instances that the enemy can fire at you. You can assign each enemy a single bullet instance but with a different damage variable randomly assigned to it when created, for example:</p>
Expand Down Expand Up @@ -181,7 +182,7 @@ <h2>Instance Method</h2>
<div>Next: <a data-xref="{title}" href="all.htm">all</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2025 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1><span data-field="title" data-format="default">self</span></h1>
}</p>
<p>In this example you can see that we have a <i>local</i> variable called <span class="inline2">val</span> and we want it to set the <i>instance</i> variable with the same name in the newly created object instance. To identify the instance variable correctly and tell <span data-keyref="GameMaker Name">GameMaker</span> to set it in the instance calling the code block, we use the <span class="inline2">self</span> keyword.</p>
<p><span class="inline2">self</span> is used in the same way with <a href="../Structs.htm">structs</a> to reference member variables of the struct. It can also be used within constructor functions to reference the struct being generated from the constructor.</p>
<p class="note"><span data-conref="../../../assets/snippets/Tag_note.hts"> </span> Due to compatibility reasons, converting <span class="inline2">self</span> into a <a data-xref="{title}" href="../../GML_Reference/Strings/string.htm">string</a> will return -1.</p>
<p class="note"><span data-conref="../../../assets/snippets/Tag_note.hts"> </span> Due to compatibility reasons, converting <span class="inline2">self</span> into a <a data-xref="{title}" href="../../GML_Reference/Strings/string.htm">string</a> will return -1, and inversely, using -1 in certain places (e.g. in a <span class="inline3_func"><a data-xref="{title}" href="../Language_Features/with.htm">with</a></span> statement) will refer to <span class="inline2">self</span>. See <a data-xref="{text}" href="../Instance_Keywords.htm#h">Legacy Values</a> for more information.</p>
<h2 id="h">When &#39;self&#39; changes</h2>
<p>Within an event or script, the current <span class="inline2">self</span> will change in the following situations:</p>
<ul class="colour">
Expand Down Expand Up @@ -104,7 +104,7 @@ <h2 id="h1">&#39;self&#39; as a reference</h2>
<div>Next: <a data-xref="{title}" href="other.htm">other</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2025 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
self
Expand Down

0 comments on commit 8e54793

Please sign in to comment.