Games-Axmud

 view release on metacpan or  search on metacpan

share/docs/guide/ch07.html  view on Meta::CPAN

<p>Click on the <strong>Attributes</strong> tab. There are two attributes which can be customised.</p>
<p><strong>Temporary hook</strong></p>
<p>If the checkbutton is selected, the hook only fires once. After that, the active hook becomes an inactive hook - it will be available again, the next time you connect to the world, but it will not be available again during this session.</p>
<p><strong>Cooldown (in seconds)</strong></p>
<p>You can prevent a hook from firing too often by setting a cooldown period. For example, if you set the cooldown to 10, after firing the hook won't be able to fire again for another 10 seconds. The default value is 0, meaning no cooldown period is ...
<h3><a name="7.5.6">7.5.6 Using hook data</a></h3>
<p>A hook's response can be an ordinary world command, a client command (like the one we created earlier, which uses <strong>';playsoundeffect'</strong>) or any other kind of instruction.</p>
<p>Those instructions include Perl commands. As explained in <a href="ch04.html#4.4">Section 4.4</a>, a Perl command is a mini-Perl programme, all on one line. The programme's return value is processed as a normal instruction such as a world command....
<p>Let's create one of these hooks now. This hook will add the word <strong>sail</strong> before every world command. It will convert <strong>north</strong> into <strong>sail north</strong> or <strong>south</strong> into <strong>sail south</strong>. ...
<p>If you're familiar with the Perl language, it will be obvious how the mini-programme works. If not, it will be obvious how to modify the mini-programme - and you can use the same mini-programme with many other hooks.</p>
<p>Don't forget that Perl commands are disabled by default. This hook won't work until you enable them again.</p>
<p>The mini-programme - including the initial forward slash character which starts all Perl commands - looks like this:</p>
<pre><code>    /my $string = 'sail '; return $string . $hookData;
</code></pre>
<p>The mini-programme's job is to convert the hook data - a string of text - into a modified string of text. The modified string is the programme's 'return value'. The return value is sent as a world command.</p>
<p>Now you're ready to create the hook.</p>
<ul>
<li>From the main window menu, click <strong>Interfaces &gt; Hooks &gt; World hooks</strong></li>
<li>In the <strong>Hook stimulus</strong> combo (drop-down) box, select <strong>sending_cmd</strong><ul>
<li>Don't select <strong>send_cmd</strong> by mistake!</li>
</ul>
</li>
<li>In the <strong>Hook response</strong> box, copy-and-paste the mini-programme from above (including the initial forward slash character and the final semicolon)</li>
<li>In the <strong>Name</strong> box, enter the name <strong>myhook2</strong></li>
<li>Click the <strong>Add</strong> button to create the hook</li>
</ul>
<p>This particular mini-programme adds the word <strong>sail</strong> to every command, but you can change <strong>sail</strong> to any word you like.</p>
<p>If you'd prefer to add a word after the original command, instead of before it, you could use this mini-programme instead:</p>
<pre><code>    /my $string = ' axe'; return $hookData . $string;
</code></pre>
<p>This mini-programme could convert the command <strong>get</strong> into <strong>get axe</strong>, the command <strong>drop</strong> into <strong>drop axe</strong> or the command <strong>sell</strong> into <strong>sell axe</strong>.</p>
<h3><a name="7.5.7">7.5.7 Redirect mode</a></h3>
<p>Astute readers might now be asking themselves why there isn't an easier way to convert <strong>north</strong> into <strong>sail north</strong> automatically.</p>
<p>In fact, there are several possible methods, including the clever use of aliases. But a much easier way is to use Axmud's <em>redirect mode</em>.</p>
<pre><code>    ;help redirectmode
</code></pre>
<h3><a name="7.5.8">7.5.8 Custom hook events</a></h3>
<p>Some users might want to create their own hook events. This is possible, though of limited use, since the only way to 'fire' the hook is with the <strong>;simulatehook</strong> command. A custom hook event has no hook data.</p>
<p>Custom hook events must begin with an underline character, followed by an alphanumeric character, for example <strong>_myevent</strong>.</p>
<p>To create a custom hook event, you can just create a hook responding to that event, for example</p>
<pre><code>    ;addhook -s _myevent -p ;about
</code></pre>
<h2><a name="7.6">7.6 Active and inactive interfaces</a></h2>
<p>As explained in detail in <a href="ch05.html">Section 5</a>, Axmud interfaces (trigger, aliases, macros, timers and hooks) are either <em>active</em> or <em>inactive</em>.</p>
<p>You can create several triggers called <strong>mytrigger</strong>, each belonging to a different profile, but only one of them is <em>active</em> (actually in use). The others are <em>inactive</em>.</p>
<p>Actually, when an interface becomes active, Axmud makes a copy of it. The copy, not the original, is the <em>active</em> interface.</p>
<p>You can see a current list of active interfaces from the main window menu (click on <strong>Interfaces &gt; Active interfaces</strong>). If the Status task is running, the list will look like this:</p>
<p><img alt="Status task interfaces" src="img/ch07/status_interfaces.png"></p>
<p>There is one more important thing to explain.</p>
<p>If you modify the original (inactive interface), the corresponding copy (active interface) is automatically updated.</p>
<ul>
<li>From the main window menu, click on <strong>Interfaces &gt; Triggers &gt; World triggers</strong></li>
<li>Enable (or disable) one of the triggers you created earlier</li>
<li>Now, from the main window menu, click on <strong>Interfaces &gt; Active interfaces</strong></li>
<li>Find the corresponding trigger in the list. It will also be enabled (or disabled)</li>
</ul>
<p>However, if you modify the copy (the active interface), <em>no changes are made to the original</em> (the inactive interface). Any changes are therefore <em>temporary</em> and will disappear at the end of the session.</p>
<h2><a name="7.7">7.7 Exporting/importing interfaces</a></h2>
<p>Everyone reading his guide will be familiar with copying and pasting.</p>
<p>In a text editor, you can highlight some text and press CTRL + C, before pressing CTRL + V to copy it to somewhere else. In between, the text is stored in some secret place in the computer's memory.</p>
<p>Axmud interfaces can also be copied from one profile to another, or even from one world to another. Axmud has a not-so secret <em>clipboard</em> which stores the interfaces waiting to be copied. This single clipboard is available to any session th...
<p>Instead of copying and pasting, we talk about <em>exporting</em> to the clipboard and <em>importing</em> from it.</p>
<ul>
<li>Connect to two worlds (in online or offline mode)</li>
<li>Click on the first world's tab, to make it visible</li>
<li>From the main window menu, click on <strong>Interfaces &gt; Triggers &gt; World triggers</strong></li>
<li>Create a trigger with a memorable name</li>
<li>Click on the trigger to select it, then click the <strong>Export</strong> button</li>
<li>Now click the second world's tab to make it visible</li>
<li>From the main window menu, click on <strong>Interfaces &gt; Triggers &gt; World triggers</strong></li>
<li>Click the <strong>Import button</strong></li>
<li>The second world receives a copy of the first world's trigger</li>
</ul>
<hr>
<p><a href="ch06.html">Previous</a> <a href="index.html">Index</a> <a href="ch08.html">Next</a></p>

</body>
</html>



( run in 0.505 second using v1.01-cache-2.11-cpan-84e82930d8c )