1. GOG.com logo

    Thanks to YOUR votes, GOG.com now sells:
    - Sea Dogs - Sea Dogs: Caribbean Tales
    - Sea Dogs: City of Abandoned Ships

    Vote now to add Pirates of the Caribbean to the list!

    Dismiss Notice
  2. Under the Crossbones Podcast

    A Pirate Podcast with Interviews
    Music, Comedy and all things Pirate!

    - Episode Guide - About - Subscribe -
    - Twitter - Facebook - iTunes - Android -
    - Youtube - Fill the Coffers -

    Dismiss Notice
  3. New Horizons logo

    Quick links for PotC: New Horizons
    - Download latest version
    - Wiki - FAQ - Report bugs here
    - ModDB profile

  4. GOF logo

    Quick links for AoP2: Gentlemen of Fortune 2
    - Downloads and info
    - Historical Immersion Supermod
    - ModDB Profile

Dismiss Notice
New to the forum?
Please take a moment to read our Welcome Message and Forum Rules.

new-horizons-Coding-102

Dec 17, 2015
new-horizons-Coding-102
  • Go back to modding

    There are two Kind of Event calls:

    Postevent(string eventname, int delay, string arguments, [arguments])
    Event(string eventname, string arguments, [arguments])ยด

    And Postevent will be "scheduled" and will run paralell to the other functions.
    And Event will be done before the rest of the code continues, so ist similar as an function call.

    In an Event function you will often see the GetEventData() function. This function picks up the arguments which are given.
    In the string arguments you declare which arguments are passed to this Event.
    You use the following letters:

    l = int
    s = string
    i = aref
    f = float

    Those are the ones I know from the top of my head at least.
    So say you want to pass a character index and experience and skillname you do it like this:
    Code:

    int idx = 0;
    int exp = 100;
    string skillname = "cannons";
    Postevent("myevent",1000,"lls",idx,exp,skillname);
    You Need a place where the Event is declared. This can be done with an Event_handler which you will see an example of in the top part of leveling.c.
    You can also use the function(I believe) SetEventHandler(string eventname, string functionname, bool something)
    I dont know what the something is, I haven't found out what is different. Maybe it has something to do with if it is allowed to run paralell or not.
    If you use the SetEventHandler you can also use the DelEventHandler(string eventname, string functionname) to remove it again.

    Say we set an Event handler for the function void fubar() and the Event Name is myevent then the fubar function would look like this:

    Code:

    void fubar()
    {
    int idx = GetEventData();
    int exp = GetEventData();
    string skillname = GetEventData();
    SomeFunctionToUseIt(idx, exp, skillname);
    }
    Now after 1 second (1000 ms) after the post Event is called this function will be executed and it will get the data which was send with the post Event.

Share This Page