Wednesday, April 1, 2009

VBS2 Internal Function Library

Some of you may not be aware of the Function Library internal to VBS2, it is a set of scripts that perform certain tasks that have been developed by BIA/BISim to help content developers simplify their tasks by using a few parameters with a call to a function name to get a result, instead of having to solve the most common problems themselves in their own script.

The reason I am bringing this up is the reference for the functions as far as I'm aware isn't in any standard documentation, you either have to dig on the forums or through the biki, so instead I'm posting a quick intro here, with links. Keep in mind that these functions can only be used inside SQF files, they can't be used directly in the editor or in SQS (another reason not to use it).

To use this library, put the following in the top of any SQF using the functions:
#include "\vbs2\headers\function_library.hpp"
Then to use a specific function from the library, add a line like this:
_returnValue = [parameters] call fn_vbs_exampleFunction;

A full list of functions by category can be found here. Keep in mind that function names are case sensitive, so use their names exactly as you see in the reference. Also, check the version number for the functions as you would a normal command, as if you try to use a function not available in your version, you will probably be disappointed by errors. As for VBS2 Lite, I have no idea what functions do and don't work, so that will largely be a trial and error thing.

If anyone is a keen scripter, yet doesn't know how to create their own function library, please post a comment, if there's enough demand to learn how to do something in particular that will guide the path of this blog, assuming the requests are reasonable in scope and the topic can be covered in a handful of posts!

Cheers,

Jamie.

4 comments:

  1. I'm trying to figure out where to put all the information if i wanted to have a speech bubble over a persons head. the function is called fn_vbs_speak

    i have no clue where to put the #include blah blah blah, information. I would LOVE a step by step guide but will settle for anything.

    ReplyDelete
  2. more detailed info can be found here.
    http://resources.bisimulations.com/wiki/fn_vbs_speak

    ReplyDelete
  3. Sorry for the delay mate, you need an SQF script file in your mission to do it, I'll assume you know nothing about scripting for the following:
    1. Once you've got a basic mission made in the editor (ensure you have a unit named man1, open up a text editor such as notepad.
    2. In notepad put the following:
    #include "\vbs2\headers\function_library.hpp"
    sleep 5;
    [man1, "Good day to you sir! This is a speech bubble!", 50] call fn_vbs_speak;
    3. Save the file as init.sqf in the mission directory (Documents\VBS2\MPMissions\. (e.g. myMission.Sara) and run the mission, you should see after about 5 seconds a speech bubble appear above man1's head with the text.

    Cheers,


    Jamie

    ReplyDelete
  4. Keep in mind with the above, your player has to be within 50 metres to see it, so you may need to adjust your mission to suit.

    ReplyDelete