• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

New Horizons Coding 102

  • Views Views: 948
  • Last updated Last updated:

Navigation

      Capturing Colonies
         A girl won in a card game
         Artois Voysey (Quest)
         Cargo for Thomas O'Reily
         Church Protection
         Edgar Attwood Adventures
         Escort Vigila Mendes Ship
         Hard Labors of an Assassin
         Help The Boatswain
         Help the Church
         Help the Lady
         Hire A Sailor - Rys Bloom
         Nigel Blythe (Quest)
         Patric and the Idols
         Rescue Peter Bloods Crew
         Sabine Matton
         Saga of the Blacque Family
         Saving Toff's Daughter
         Search for Peter Bloods Ship
         Silver for Cartagena
         Sink the Pirate Corvette
         Sinking The Vogelstruijs
         Smuggling for Thomas O'Reily
         The Silver Train
         Zaid Murro's Problems
      Smuggling
      Treasure Quests
         Lost Treasure on Cuba
         Lost Treasure on Guadeloupe
  • 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.
Back
Top