[Client Scripting] Load of 2 Client Scripts

Discussion in 'Server and Client Scripting' started by Teutonic Knight, Jul 9, 2013.

  1. Teutonic Knight

    Teutonic Knight Banned

    Joined:
    Jul 2, 2013
    Messages:
    75
    Likes Received:
    0
    PO Trainer Name:
    William Hlas
    Okay, well I'm posting this to ask, is there away to load two client scripts at once? Now, you're wondering why two? Well, one is TUO's basic client script, and then I have Bot script, and I'd like to load both on account of logging into a server, so is there a possibility?
     
  2. Wanderer M

    Wanderer M Dancer

    Joined:
    Sep 14, 2011
    Messages:
    36
    Likes Received:
    0
    PO Trainer Name:
    Wanderer M
    No, that's not possible. You'll have to merge the two scripts together yourself (or ask someone else to do that for you).
     
  3. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    There is my (fairly old) ScriptLoader, but it tends to break and doesn't always really work. Maybe I'll give it another shot and try to improve it, as it's certainly possible. Or, of course, scripters could use a single scriptloader API, but that's probably not going to happen.
     
  4. Teutonic Knight

    Teutonic Knight Banned

    Joined:
    Jul 2, 2013
    Messages:
    75
    Likes Received:
    0
    PO Trainer Name:
    William Hlas
    Okay, I'll see about the scriptloader, but thanks for the help guys!
     
  5. ArchZombie

    ArchZombie Member

    Joined:
    Aug 1, 2012
    Messages:
    65
    Likes Received:
    0
    PO Trainer Name:
    ArchZombie0x
    If you need an improved scriptloader I could write one for you (if that one has issues), but that assumes the script doesn't use global variables. If a script uses global variables, you can only use one at a time if the variables conflict.

    EDIT: I see it isn't really a "scriptloader" more like a script plugin manager.

    Here's a script loader thingy:

    Code (javascript):
    1. (function (scripts) {
    2.  
    3.     function bind (t, f)
    4.     {
    5.         return function () { f.call(t, arguments); }
    6.     }
    7.    
    8.     function multifuse (functions)
    9.     {
    10.         return function () { for (var x in functions) functions[x].call(new Object, arguments) }; }
    11.     }
    12.  
    13.     var outputs = new Object;
    14.  
    15.     for (var x in scripts)
    16.     {
    17.         for (var x2 in scripts[x])
    18.         {
    19.             if (typeof scripts[x][x2] === "function")
    20.             {
    21.                 (outputs[x2] || outputs[x2] = []).push(bind(scripts[x], scripts[x][x2]));
    22.             }
    23.         }
    24.     }
    25.  
    26.     var script_out = new Object;
    27.  
    28.     for (var x in outputs)
    29.     {
    30.         script_out[x] = multifuse(outputs[x]);
    31.     }
    32.  
    33.     return script_out;
    34.    
    35. })([sys.exec("script1.js"), sys.exec("script2.js")]);
    Untested, just wrote :)
     
    Last edited: Jul 9, 2013