Currency changeSolved

Is it possible for you to add a custom cost other than scrap? Research paper is used on my pve server and this would be a great addidtion! currently I have the tech tree disabled because I'm using research paper for researching in the research table combined with the XP revivied plugin.

That should be pretty simple to add, but the main issue is the user experience isn't optimal since the tech tree UI cannot be changed. Best we could do is show a UI when the workbench is opened, to help set the player's expectations, and show a temporary UI after a player tries to unlock something, to tell them how much they were charged or what currency/amount they lack.

To set expectations, this plugin is pretty low priority for me, so i haven't scheduled when or even if I will spend time to address the above issues. Your best options to move forward in the short term are to get someone else to contribute the functionality to this plugin, or to seek a different plugin such as an entitely custom tech tree solution.

Even if the plugin just had the code in it for Research paper functionality that would be absoloutely fine mate. Am not worried about the UI to be honest. I can quite easily get around that.
You can PM me the line of code and where to add it if you don't want it publically in your plugin.

The plugin doesn't currently determine the currency type. That's determined by vanilla, and the plugin simply uses the OnResearchCostDetermine hook to specify the scrap amount.

To move forward, add a hook like this to the plugin code.

private bool? OnTechTreeNodeUnlock(Workbench workbench, TechTreeData.NodeInstance node, BasePlayer player)
{
    var requiredItemAmount = _pluginConfig.GetResearchCostOverride(node.itemDef);
    var itemid = -544317637;

    if (player.inventory.GetAmount(itemid) >= requiredItemAmount)
    {
        player.inventory.Take(null, itemid, requiredItemAmount);
        player.blueprints.Unlock(node.itemDef);
        Interface.CallHook("OnTechTreeNodeUnlocked", workbench, node, player);
    }

    return false;
}

You sir, are a legend! I am currently going away for three days but I will play with this when I get home!

Ok so I've finally got round to playing with this. Been so busy recently. CAn you guide me where to put this in as I tried it yesterday morning and I got a compile error lol. I'm not too great at scripting.

I just checked and found that code above doesn't compile. Try the following code instead.

private bool? OnTechTreeNodeUnlock(Workbench workbench, TechTreeData.NodeInstance node, BasePlayer player)
{
    var requiredItemAmount = _pluginConfig.GetResearchCostOverride(node.itemDef) ?? ResearchTable.ScrapForResearch(node.itemDef);
    var itemid = -544317637;

    if (player.inventory.GetAmount(itemid) >= requiredItemAmount)
    {
        player.inventory.Take(null, itemid, requiredItemAmount);
        player.blueprints.Unlock(node.itemDef);
        Interface.CallHook("OnTechTreeNodeUnlocked", workbench, node, player);
    }

    return false;
}

That works thanks!

Have got compilation errors again, using the last two custom pices of code you mentioned before. 
Would it be too difficult to integrate a permanent config option to select a custom currency for the tech tree?

It works perfectly thank you!

Locked automatically