Scripting Caveats

  • Problem: Wrong / garbled output
    • Example: LouisC just listened to »/> ”/>U”/>n”/>t”/>i”/>l”/> ”/>t”/>h”/>e”/> ”/>E”/>n”/>d« by D”/>r”/>a”/>g”/>o”/>n”/>l”/>o”/>r”/>d”/> ”/.
    • Solution: Add the following line to the Script before returning the output: set AppleScript's text item delimiters to ””
  • Problem: Script does not return anything
    • Example: N/A
    • Solution: Make sure that the script's name does not equal the first returned word. If it has to (for whatever reason) make sure a delimiter sign such as ”:” is added to that word.

Script Template

Below is a script template that you should consider using to unify the appearance of scripts throughout Linkinus. The parameter in “linkinuscmd()” is optional and may be removed by you.

-- Script Name: …
-- Version: …
-- Description: …
-- Author: …

on linkinuscmd(parameter)
…
end linkinuscmd

-- Changelog:
-- X.Y:
-- - …
-- - …
-- C.V:

Using PHP

You can use PHP for your scripts. You need “extscript” to run the php-files.

Perhaps you need to update the “extscript”. If so, you have to update the two file paths to Linkinus 2:

set p to p & "Linkinus 2/Scripts/External/"
set test to searchReplace((alias (a as string)) & "Linkinus 2:Scripts:External:", "::Linkinus", "")

Everything else is explained in the section about extscript.

You can then use echo to send something to the chat. Use something like the following for debugging. Nothing will be send to the chat then, just shown to you like explained in the section debugging echo

    ob_start();
    echo '/debug echo ';
 
    print_r( $argv );
    // echo '1' . "\r\n";
 
    echo ob_get_clean();

If you add there Lines to the extscript, you can pass additional parameters to your $argv Array in PHP:

set AppleScript's text item delimiters to " "
set scriptName to get first text item of parameter
set argv to searchReplace(parameter, scriptName & "", "")

Notice: I renamed scriptName in the handler to parameter!

Scripting Resources

 
creating_scripts.txt · Last modified: 2011/12/27 14:28 by layneobserdia
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki