gm-docs-parser 1.0.0

A collection of typings for GameMaker Studio 2 manual pages
Documentation
<?xml version="1.0" encoding="utf-8" ?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>

  <script type="text/javascript" language="JavaScript">
    //<![CDATA[
    function reDo() {
      if (innerWidth != origWidth || innerHeight != origHeight)
        location.reload();
    }
    if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
      origWidth = innerWidth;
      origHeight = innerHeight;
      onresize = reDo;
    }
    onerror = null;
  //]]>
  </script>
  <style type="text/css">/*<![CDATA[*/

    < !-- div.WebHelpPopupMenu {
      position: absolute;
      left: 0px;
      top: 0px;
      z-index: 4;
      visibility: hidden;
    }

    p.WebHelpNavBar {
      text-align: right;
    }

    -->
  
/*]]>*/</style>

  <script type="text/javascript">//<![CDATA[

    gRootRelPath = "../../../..";
    gCommonRootRelPath = "../../../..";
    gTopicId = "9.2.2.7.0_3";
  
//]]></script>

  <script type="text/javascript" src="../../../../template/scripts/rh.min.js"></script>
  <script type="text/javascript" src="../../../../template/scripts/common.min.js"></script>
  <script type="text/javascript" src="../../../../template/scripts/topic.min.js"></script>
  <script type="text/javascript" src="../../../../template/scripts/topicwidgets.min.js"></script>
<script type="text/javascript" src="../../../../whxdata/projectsettings.js"></script>
  <link rel="stylesheet" type="text/css" href="../../../../template/styles/topic.min.css"/>
  <link rel="stylesheet" type="text/css" href="../../../../template/Charcoal_Grey/topicheader.css"/>
  <meta name="topic-status" content="Draft"/>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>script_execute</title>
  <meta name="generator" content="Adobe RoboHelp 2019"/>
  <link rel="stylesheet" href="../../../../assets/css/default.css" type="text/css"/>
  <meta name="rh-authors" content="Mark Alexander"/>
  <meta name="topic-comment" content="Page explaining the function script_execute"/>
  <meta name="rh-index-keywords" content="script_execute"/>
  <meta name="search-keywords" content="script_execute"/>
</head>

<body>
  <div class="topic-header rh-hide" id="rh-topic-header" onclick="rh._.goToFullLayout()">
    <div class="logo">
    </div>
    <div class="nav">
      <div class="title" title="script_execute">
        <span>script_execute</span>
      </div>
      <div class="gotohome" title="Click here to see this page in full context">
        <span>Click here to see this page in full context</span>
      </div>
    </div>
  </div>
  <div class="topic-header-shadow rh-hide" id="rh-topic-header-shadow"></div>



  <!--<div class="body-scroll" style="top: 150px;">-->
  <h1>script_execute</h1>
  <p>This function was originally designed for calling script <i>assets</i> in a dynamic way, but with the introduction of user-defined functions it can now be used in two ways:</p>
  <ul class="colour">
    <li>The first way is to support <b>legacy</b> scripts, where each script was a single function and the title of the script was also the name of the function. Used in this way, it will work as before and It will run a user created
      script asset and pass the given arguments into it. Note that it isn&#39;t actually calling the <i>script</i> in this case but, the <i>script function</i> of the same name within the script.
      <span style="text-align: justify;"></span>
    </li>
    <li><span style="text-align: justify;">The second way is to call a function from a script asset that contains multiple functions or variable definitions. In this case you would provide the function name and the arguments it requires rather than the script asset name. Note that this will only work for <a href="../../../GML_Overview/Script_Functions.htm">script functions</a> and not for <a href="../../../GML_Overview/Method_Variables.htm">methods</a>, as only script functions have a script ID assigned to them.</span></li>
  </ul>
  <p><span style="text-align: justify;"></span>While this function is designed primarily for legacy support it is not deprecated as it still has it&#39;s place in networking and remote procedure call situations. It is also worth noting that this function
    is slow, and using it a lot may adversely affect performance.</p>
  <p> </p>
  <h4>Syntax:</h4>
  <p class="code">script_execute(scr, arg0, arg1, arg2..., etc...);</p>
  <table>
    <tbody>
      <tr>
        <th>Argument</th>
        <th>Description</th>
      </tr>
      <tr>
        <td>scr</td>
        <td>The name of the function/script that you want to call</td>
      </tr>
      <tr>
        <td>arg0, arg1, arg2..., etc...</td>
        <td>The different arguments that you want to pass through to the function/script</td>
      </tr>
    </tbody>
  </table>
  <p> </p>
  <h4>Returns:</h4>
  <p class="code">Will depend on the return value from the script/function being called</p>
  <p> </p>
  <h4>Example:</h4>
  <p class="code">script_execute(choose(move_up, move_down, move_left, move_right), irandom(5));</p>
  <p>The above example code will use <tt>script_execute</tt> to choose one of four user defined functions (in this case related to movement) and pass a random integer to it as the first argument.</p>
  <p> </p>
  <p> </p>
  <p> </p>
  <div class="footer">
    <div class="buttons">
      <div class="clear">
        <div style="float:left">Back: <a href="Scripts.htm">Scripts</a></div>
        <div style="float:right">Next: <a href="script_execute_ext.htm">script_execute_ext</a></div>
        <div style="float:right"> </div>
      </div>
    </div>
    <h5>© Copyright YoYo Games Ltd. 2020 All Rights Reserved</h5>
  </div>
  <!-- KEYWORDS
script_execute
-->
  <!-- TAGS
script_execute
-->

</body></html>