[TUTORIAL] ChaiScript for IW5

Topic created · 1 Posts · 985 Views
  • ChaiScript and you.

    Hi all! With the announcement of PlutoIW5, I want to follow up with a post about how we have enabled mod support. The dev team have decided to move away from compiled GSC and instead opted to use an external scripting language called ChaiScript. It is similar to GSC and C++, and we recommend reading the documentation here and their cheat sheet here. These 2 sources should be able to get you up and running so you can run mods on your dedicated server.


    The developers have also enabled users to extend the functionality and capabilities of ChaiScript, allowing for plugins to be loaded on servers. For example, there can be a plugin that allows for reading and writing of files to and from the disk.


    How ChaiScript?

    ChaiScript does not allow for external GSC scripts to be included (like how you typically make mods for IW4 or T6), so only internal functions can be called, like getXuid() or iPrintlnBold(). So what does that mean? It means you will have to write your own implementations of functions if they were something you typically referenced in old GSC scripts. Let's write a script that waits for a player to spawn and then sends them a message when they are spawned in:

    level.onNotify("connected", fun(arguments) {
    	var player = arguments[0];
    	
    	player.onNotify("spawned_player", fun[player](arguments) {
    		helloWorld(player);
    	});
    });
    
    def helloWorld(player)
    {
    	player.iPrintlnBold("^1Hello, world!");
    }
    

    Save the script as hello.chai and place the script in %localappdata%\Plutonium\storage\iw5\scripts\
    Start your dedicated server and join it, and you should be greeted by something like this once you spawn:
    Hello, world!


    DLL Plugin

    As mentioned previously, the developers have enabled us to extend the functionality of ChaiScript through the use of plugins, which need to be programmed in C++. We have a Visual Studio project that is setup, which will be provided near the end of this post. After downloading and extracting the files to make a plugin, open it in Visual Studio and make sure your settings look like this:



    PLEASE NOTE: THIS MUST BE COMPILED AS x86 AND AS A RELEASE BUILD!
    To get started with adding functionality through our plugin system, please take a look here.

    Plugin VS Project


    Suggested Plugins

    Adds extended functionality to our scripting system, allowing access to more callbacks: https://github.com/xensik/plutoscript
    Allows access to the filesystem for reading and writing files to disk: https://github.com/StaRT1337/PlutoniumFilesystem

Log in to reply