Scripting Help



  • In the past I've managed to get a hold of some modules that people have asked me to do work on, but I've never understood how they've done certain things. Like adding new custom functions to the function list and customized the spells. How does one do this?



  • To customise spells you can just edit the spell script that particular spell uses, though, that's not very maintainable, it's probably better to create an include file with all your spell scripts in it, and use spell hooking to send the spell through that, to the right function, depending on what spell was cast (and any other factors)

    How to create functions…. well... that's a general scripting thing really but... hum.

    You need to 'prototype' your function first.

    void myFunction(int parameter1, string parameter2);
    

    for instance, and that should be (often placed above the main() function.

    Then you 'define' the function itself.

    void myFunction(int parameter1, string parameter2)
    {
         if(ZoolIsAwesome)
         {
                SendMessageToAllDMs("Well, that was obvious");
         }
    }
    

    Then you need to call the function within your actual code, which is (probably) within the main() function

    main()
    {
     LOADS OF SCRIPT AND STUFF
    
        myFunction(variableYouSendInAsParameter1, VariableYouSendInAsParameter2);
    }
    

    Not sure how much help that is.



  • Also it would probly cause an infinite loop because I AM ALWAYS AWESOME


  • Admin [DM]

    @Zool:

    Also it would probly cause an infinite loop because I AM ALWAYS AWESOME

    Looks like we found the source of the infinite loop issue 😉


Log in to reply