PenUltima Online

It is currently Fri Sep 05, 2008 8:36 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: start_script(commmand, who, par)
PostPosted: Wed Jan 31, 2007 5:36 am 
Offline

Joined: Sat Feb 04, 2006 10:13 am
Posts: 12
Location: Livorno Italy
start_script(commmand, who, par)

to launch text command and pass parameters?

_________________
-----------------------------------------
Zandor
Scripter ZHI Shard


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 6:34 am 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
You may already know this but just in case, you use an array of paramaters. Start_Script("script", array{who, par}), and handle it accordingly in your script.

Code:
program TextCmd(who, textcmd)
  if ( Lower(TypeOf(who) == "array" ) // it's being passed by a Start_Script()
    textcmd := who[2];
    who := who[1];
  endif

...
end program


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 6:57 am 
Offline

Joined: Sat Feb 04, 2006 10:13 am
Posts: 12
Location: Livorno Italy
Yes I know but a thing is a generic mode to launch EVERY textcmd command (more flexible) and another is a workaround to launch some textcmd with special parameter handling....

Anymore was a very stupid thing, none special.

_________________
-----------------------------------------
Zandor
Scripter ZHI Shard


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 1:31 pm 
Offline

Joined: Wed May 10, 2006 5:15 pm
Posts: 113
The generic method is a better solution, because... well... it's generic.

Rather than alter the way the code works, adding an entire list of useless script launchers, why not just either:

  1. Externalize the code you want to launch, and use functions instead of launching another script?

    textcmd.src
    Code:
    include "textcmd.inc";

    program _TextCmd(who, text)
        TextCmd(who,text);
    endprogram


    textcmd.inc
    Code:
    function TextCmd(byref who, text)
        // Do stuff.
    endfunction


    MyFunctions.src
    Code:
    include "textcmd.inc";

    program MyProgram(...)
        //...
        TextCmd(who,text);
        //...
    endprogram
  2. Write your own function so that the parameters are easier for you?

    textcmds.inc
    Code:
    function LaunchTextCmd(command, byref who, text)
        StartScript(command, array{ who, text } );
    endfunction

    function testTCParms( byref first_parm, byref second_parm )
        if( TypeOf(first_parm) == "Array" )
            second_parm := first_parm[1];
            first_parm := first_parm[2];
        endif
    endfunction


    Every Text Command
    Code:
    include "textcmds.inc";

    program TextCmd(who, text)
        testTCParms(who,text);
        // Do textcmd stuff.
    endprogram


Either way, it'll take a little bit of time; but if it can be done with a script without causing any trouble in performance, it should.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl